android - Collapsing Toolbar Layout expand on click event and not on scroll -


i have simple toolbar info icon item on right. when click on item expand toolbar animation. new view , fab button. textra sms doing.

when clicking outside expanded toolbar, want colapse toolbar.

i looking how can handle collapsingtoolbarlayout? possible? example find on web collapsing/expanding scroll of the view (recyclerview, scrollview etc...). don't want toolbar move when scrolling view.

it way use collapsingtoolbarlayout? or need myself?

collapsingtoolbarlayout seems fine purpose (and believe make layout better 1 in textra sms app).

you need few things:

  1. a way disable collapsingtoolbarlayout. best way in opinion (at least best found far) use custom coordinatorlayout instead of regular coordinatorlayout.

    public class disableablecoordinatorlayout extends coordinatorlayout {     private boolean mpassscrolling = true;      public disableablecoordinatorlayout(context context) {         super(context);     }      public disableablecoordinatorlayout(context context, attributeset attrs) {         super(context, attrs);     }      public disableablecoordinatorlayout(context context, attributeset attrs, int defstyleattr) {         super(context, attrs, defstyleattr);     }      @override     public boolean onstartnestedscroll(view child, view target, int nestedscrollaxes) {         return mpassscrolling && super.onstartnestedscroll(child, target, nestedscrollaxes);     }      public void setpassscrolling(boolean passscrolling) {         mpassscrolling = passscrolling;     } } 
  2. you need disable collapsingtoolbarlayout (you don't want collapsingtoolbarlayout react scrolls anymore):

    mdisableablecoordinatorlayout.setpassscrolling(false); 
  3. you need use appbarlayout expand collapsingtoolbarlayout onoptionsmenu item click

    mappbarlayout.setexpanded(true, true); 
  4. you need use appbarlayout collapse collapsingtoolbarlayout on click outside (implement click outside in way feel like)

    mappbarlayout.setexpanded(false, true); 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -