android - Handling scroll of AppBarLayout not working(ToolBar doesn't collapse) -


i trying collapse toolbar + image , stick minimum height. its's not working, posting code. appreciated.

using these below links reference

https://guides.codepath.com/android/handling-scrolls-with-coordinatorlayout#expanding-and-collapsing-toolbars

http://blog.grafixartist.com/toolbar-animation-with-android-design-support-library/

below code xml

<?xml version="1.0" encoding="utf-8"?> <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:fitssystemwindows="true">  <android.support.design.widget.appbarlayout     android:id="@+id/appbar"     android:layout_width="match_parent"     android:layout_height="192dp"     android:fitssystemwindows="true"     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"         android:fitssystemwindows="true"         app:contentscrim="?attr/colorprimary"         app:expandedtitlemarginend="64dp"         app:expandedtitlemarginstart="48dp"         app:layout_scrollflags="scroll|exituntilcollapsed">          <android.support.v7.widget.toolbar             android:id="@+id/anim_toolbar"             android:layout_width="match_parent"             android:layout_height="?attr/actionbarsize"             app:layout_scrollflags="scroll|enteralways"             app:popuptheme="@style/themeoverlay.appcompat.light"/>         <!--            app:layout_collapsemode="pin"         -->          <imageview             android:id="@+id/header"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:background="@drawable/header"             android:fitssystemwindows="true"             android:minheight="100dp"             android:scaletype="centercrop"             app:layout_collapsemode="parallax"             app:layout_scrollflags="scroll|enteralways|enteralwayscollapsed"/>     </android.support.design.widget.collapsingtoolbarlayout> </android.support.design.widget.appbarlayout>  <android.support.v7.widget.recyclerview     android:id="@+id/scrollableview"     android:layout_width="match_parent"     android:layout_height="match_parent"     app:layout_behavior="@string/appbar_scrolling_view_behavior"/>  </android.support.design.widget.coordinatorlayout> 

and class code

public class groupchatdetailsactivity extends appcompatactivity {       int mutedcolor = r.attr.colorprimary;     groupchatdetailsadapter groupchatdetailsadapter;     private collapsingtoolbarlayout collapsingtoolbar;     private recyclerview recyclerview;      @override     protected void oncreate (bundle savedinstancestate) {         super.oncreate (savedinstancestate);         setcontentview (r.layout.group_details_layout);         setup ();     }      private void setup () {         toolbar toolbar = (toolbar) findviewbyid (r.id.anim_toolbar);         setsupportactionbar (toolbar);         getsupportactionbar ().setdisplayhomeasupenabled (true);          collapsingtoolbar = (collapsingtoolbarlayout) findviewbyid (r.id.collapsing_toolbar);         collapsingtoolbar.settitle ("test title");          imageview header = (imageview) findviewbyid (r.id.header);         bitmap bitmap = bitmapfactory.decoderesource (getresources (),                 r.drawable.header);          palette.from (bitmap).generate (new palette.paletteasynclistener () {             @suppresswarnings ("resourcetype")             @override             public void ongenerated (palette palette) {                 mutedcolor = palette.getmutedcolor (r.color.primary_500);                 collapsingtoolbar.setcontentscrimcolor (mutedcolor);                 collapsingtoolbar.setstatusbarscrimcolor (r.color.black_trans80);             }         });          recyclerview = (recyclerview) findviewbyid (r.id.scrollableview);         recyclerview.sethasfixedsize (true);         linearlayoutmanager layoutmanager                 = new linearlayoutmanager (this);         recyclerview.setlayoutmanager (layoutmanager);          list<string> listdata = new arraylist<string> ();         int ct = 0;         (int = 0; < versionmodel.data.length * 2; i++) {             listdata.add (versionmodel.data[ct]);             ct++;             if (ct == versionmodel.data.length) {                 ct = 0;             }         }         if (groupchatdetailsadapter == null) {             groupchatdetailsadapter = new groupchatdetailsadapter (listdata);             recyclerview.setadapter (groupchatdetailsadapter);         }     } } 

not sure why fitsystemwindows on coordinatorlayout breaking this. put coordinatorlayout inside framelayout (and move fitsystemwindows=true framelayout).


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -