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:
a way disable
collapsingtoolbarlayout
. best way in opinion (at least best found far) use customcoordinatorlayout
instead of regularcoordinatorlayout
.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; } }
you need disable
collapsingtoolbarlayout
(you don't wantcollapsingtoolbarlayout
react scrolls anymore):mdisableablecoordinatorlayout.setpassscrolling(false);
you need use
appbarlayout
expandcollapsingtoolbarlayout
onoptionsmenu item clickmappbarlayout.setexpanded(true, true);
you need use
appbarlayout
collapsecollapsingtoolbarlayout
on click outside (implement click outside in way feel like)mappbarlayout.setexpanded(false, true);
Comments
Post a Comment