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?

correct behavior 23.4.0

in following gif can see how there no button. when add layout_behavior "loses" postion.

button disappear!!

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

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -