android - FloatingActionButton setVisibility() not working -
i can't hide floatingactionbutton
. here code:
xml:
<coordinatorlayout> <appbarlayout android:id="@+id/appbar"> <collapsingtoolbarlayout> <imageview/> <android.support.v7.widget.toolbar /> </collapsingtoolbarlayout> </appbarlayout> <nestedscrollview /> <android.support.design.widget.floatingactionbutton android:id="@+id/fab" app:layout_anchor="@id/appbar" app:layout_anchorgravity="bottom|right|end"/> </coordinatorlayout>
and i'm calling:
fab.clearanimation(); fab.setvisibility(view.gone);
i'm trying hide fab, seems setvisibility
+ clearanimation
not work if fab in coordinatorlayout
.
even if call fab.clearanimation
, animation still triggered. can me?
if issue animation, try invalidating fab behavior
. visibility, should null anchor have set in layout:
coordinatorlayout.layoutparams p = (coordinatorlayout.layoutparams) fab.getlayoutparams(); p.setbehavior(null); //should disable default animations p.setanchorid(view.no_id); //should let set visibility fab.setlayoutparams(p); fab.setvisibility(view.gone); // view.invisible might worth trying //to bring things normal state coordinatorlayout.layoutparams p = (coordinatorlayout.layoutparams) fab.getlayoutparams(); p.setbehavior(new floatingactionbutton.behavior()); p.setanchorid(r.id.appbar); fab.setlayoutparams(p);
Comments
Post a Comment