Scalified / fab

Floating Action Button Library for Android
Apache License 2.0
849 stars 164 forks source link

Needs compatible method with new CoordinatorLayout. #31

Closed XinyueZ closed 9 years ago

XinyueZ commented 9 years ago

Hi,

it should be nice that the new CoordinatorLayout of design-lib gives behavior-relationship to your "fab" instead the FAB of design-lib self. I've tried but it throws exception to cast fab to FAB of design-lib. With the behavior we can move the "fab" up automatically against Snackbar of design-lib.

vbaidak commented 9 years ago

Hi XinyueZ,

There is no possibility to perform such cast because this is how Java works

Despite the fact that classes com.software.shell.fab.ActionButton and android.support.design.widget.FloatingActionButton both extends android.view.View class they can't be casted to each other because no one of them is the superclass of the other and vice versa. In this case you'll get java.lang.ClassCastException. Always.

There are no plans to extend the com.software.shell.fab.ActionButton class from android.support.design.widget.FloatingActionButton in order to "make" it work with the new layouts. Furthermore, looking ahead I can say that starting from version 2.0.0 com.software.shell.fab.ActionButton will be extended from android.view.SurfaceView class, which in turn extends the android.view.View class

So for your case you have 2 choices:

  1. Use the com.software.shell.fab.ActionButton AS-IS and fit it to the layout you are using. Use convenient move methods for this
  2. Use the android.support.design.widget.FloatingActionButton from the android design support library
XinyueZ commented 9 years ago

nice to know.