I have a "Problem" toolbar with the caption text "Do not collapse when scrolling up in CollapsingToolbarLayout".
I tried several settings using app: layout_collapseMode = "none" as an attribute in my android.support.v7.widget.Toolbar but it doesnโt work. There may be a problem with my layout.
Below I am trying to achieve.

But when I scroll up, the panel also collapses, and the tabBar also scrolls inward and becomes invisible. Below is what I have now.

This is my layout code.
<android.support.design.widget.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:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapsing_toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" app:contentScrim="?attr/colorPrimary" app:layout_scrollFlags="scroll|enterAlways"> <FrameLayout android:layout_width="match_parent" android:layout_height="250dp" app:layout_collapseMode="parallax" app:layout_collapseParallaxMultiplier="0.7"> <ImageView android:id="@+id/backdrop" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" /> <View android:layout_width="match_parent" android:layout_height="match_parent" android:background="#20000000" /> </FrameLayout> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:layout_collapseMode="none" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Application Title" android:textColor="#fff" android:textSize="18sp" /> </android.support.v7.widget.Toolbar> </android.support.design.widget.CollapsingToolbarLayout> <android.support.design.widget.CollapsingToolbarLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_scrollFlags="scroll|enterAlways"> <android.support.design.widget.TabLayout android:id="@+id/detail_tabs" android:layout_width="match_parent" android:layout_height="60dp" app:layout_collapseMode="pin" android:background="#00000000" app:tabSelectedTextColor="#3498db" app:tabTextColor="#000" /> /> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> <android.support.v4.view.ViewPager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#333" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> </android.support.design.widget.CoordinatorLayout>
Dependencies
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile "com.android.support:appcompat-v7:22.2.1" compile "com.android.support:support-annotations:22.2.1" compile "com.android.support:design:22.2.1" compile 'com.android.support:recyclerview-v7:22.2.1' compile 'com.android.support:cardview-v7:22.2.1' }
source share