android - Quirk with custom Layout Behavior when updating to Support Library 24 -
in last couple of project i've worked on had custom layout behavior button mimick animation floatingbutton makes when snackbar shown. code used is:
public class behaviorbutton extends coordinatorlayout.behavior<button> { public behaviorbutton(context context, attributeset attrs) {} @override public boolean layoutdependson(coordinatorlayout parent, button child, view dependency) { return dependency instanceof snackbar.snackbarlayout; } @override public boolean ondependentviewchanged(coordinatorlayout parent, button child, view dependency) { float translationy = math.min(0, dependency.gettranslationy() - dependency.getheight()); child.settranslationy(translationy); return true; } }
and "bind" class button through xml.
app:layout_behavior=".behaviorbutton"
nothing special. the problem: when updated support libraries 23.4.0 24 functionality disappeared. question is: how supposed implement such behavior in support library 24?
in following gif can see how there no button. when add layout_behavior
"loses" postion.
you need check if dependency snackbarlayout
, translate button.
@override public boolean ondependentviewchanged(coordinatorlayout parent, button child, view dependency) { if(dependency instanceof snackbar.snackbarlayout){ float translationy = math.min(0, dependency.gettranslationy() - dependency.getheight()); child.settranslationy(translationy); return true; } return false; }
Comments
Post a Comment