I am using below layout to use collapsing toolbar effect but not able to expand toolbar.I want to expand the toolbar as given here for collapsing toolbar effect. https://guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="192dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:scrollbars="horizontal"
android:layout_below="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primaryColor"
app:layout_scrollFlags="scroll|enterAlways" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/tabanim_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
Guide me with any corrections.
I suppose that the view with
app:layout_behavior="@string/appbar_scrolling_view_behavior"
has to be scrollable vertically, whichViewPager
is not. I am not quite sure whether wrapping theViewPager
into someScrollView
would help. Most probably it would cause some problems with touch event handling. If the page within yourViewPager
is scrollable, you should set theapp:layout_behavior
directly to its scrollable view but I am not sure this would work as expected either. The collapsing toolbar effect is not meant to work this way and it is not yet perfect even when used as intended.Use design support library http://android-developers.blogspot.in/2015/05/android-design-support-library.html
include this in build.gradle
for recycler view include this also
Your activity should extend AppCompatActivity
Your app theme should be like this