-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support for CoordinatorLayout #61
Comments
Until it's officially added it can be accomplished by creating a behavior. Here what I am currently using with my instance of FloatingActionMenu https://gist.github.com/lodlock/e3cd12130bad70a098db it can be easily modified to work with a FloatingActionButton as well. |
+1 |
Hello lodlock, I put your java class file to my project and I added the line to the FloatingActionMenu in xml: <com.github.clans.fab.FloatingActionMenu
app:layout_behavior="cz.yetanotherview.webcamviewer.app.helper.FloatingActionMenuBehavior"
android:id="@+id/floating_action_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom|end"
android:paddingRight="10dp"
android:paddingBottom="8dp"
android:paddingLeft="10dp"
fab:menu_shadowColor="#37000000"
fab:menu_colorNormal="#DA4336"
fab:menu_colorPressed="#E75043"
fab:menu_colorRipple="#99FFFFFF"
fab:menu_icon="@drawable/fab_add"
fab:menu_buttonSpacing="10dp"
fab:menu_labels_textColor="@color/very_dark_grey"
fab:menu_labels_textSize="14sp"
fab:menu_labels_colorNormal="@color/white"
fab:menu_labels_colorPressed="@color/next_grey"
fab:menu_labels_colorRipple="#99FFFFFF"
fab:menu_labels_margin="8dp"
fab:menu_backgroundColor="@color/black_transparent"> that resides within a CoordinatorLayout and then I create the Snackbar: Snackbar.make(findViewById(R.id.coordinator_layout), R.string.dialog_positive_toast_message,
Snackbar.LENGTH_SHORT).show(); but Snackbar overlaps FloatingActionMenu, like without your behavior. Any idea? |
Is your FloatingActionMenu inside of a CoordinatorLayout? If it is and you are still having issues you can extend the FloatingActionMenu itself and build the Behavior into it as an inner class. This way you wont need to include layout_behavior at all. This also fixes an issue where adding a layout_behavior sometimes causes Android Studio to not preview your layout anymore. If that isn't an option for you you could do this dirty work around but it is not recommended. You can add an additional CoordinatorLayout wrapping only the FloatingActionMenu and use it for your Snackbar calls. It works but it's dirty. |
Yes, |
So I made simple solution only until it's not officially added ;) |
A small update to @lodlock 's solution for handling the Floating Action Menu hide/show on scroll. |
It looks like to implement this I'm gonna need to use a support design library as a dependency. I think it'll be inconvenient to have that inside a library module and in some cases - redundant. So I believe the best approach here is to use the custom Behavior that was provided in previous comments. |
Hello Matteo, I tried also your solution, but only hide/show on scroll is working (FloatingActionMenu is inside of a CoordinatorLayout). Any idea why is not working also with Snackbars? |
Hi @TomasValenta, |
Yes, |
@mmazzarolo Doesn't work for me. |
Make sure you're using the right attribute prefix of <com.github.clans.fab.FloatingActionMenu
...
app:layout_behavior="com.your.company.package.FloatingActionMenuBehavior"
>
...
</com.github.clans.fab.FloatingActionMenu> Working great for me!! Thanks!!! |
I just pushed a PR #156 with 2 CoordinatorLayout.Behavior classes to support floating action button and menu. There is also some sample code in the PR. Also, as the FloatingActionButton and FloatingActionMenu classes are annotated with @CoordinatorLayout.DefaultBehavior, you don't need to add the app:layout_behavior attribute in your XML layout anymore. |
adding app:layout_behavior do nothing. In fact, it does not exist, I adding it manually.
I can't make it to work. The FAB is still floating even scroll down. |
@mmazzarolo I tried your behavior class but it is not working. I've defined the layout_behavior for the FloatingActionMenu inside a CoordinatorLayout. Any suggestions? Using latest design support lib. |
@xsorifc28
|
@abramov73 it says that it's not overriding the super class, and onNestedFling is undefined. |
@AndreyNazarchuk u need to add this into this file: |
@w3ggy 404 :-/ |
I tried to implement this behavior it works well on an emulator but weird results on a real device. The fab slides up out of sync with the snack bar and it does not slide back down when snack bar closes, both emulator and device run the same android version (Marshmallow) |
Does anyone know how to anchor the FAM to a CollapsingToolbarLayout in a CoordinatorLayout?? |
still facing problems with snackbar, is there any fix? |
When I use the FAM with a CollapsingToolbarLayout the button appears below the appbar. Any solution for this? |
Not able to get it work as getting error Error:(52) No resource identifier found for attribute 'layout_behavoir' in package `
</android.support.design.widget.CoordinatorLayout>
}` and main activity implementation |
Hello again,
it's possible to implement support for new CoordinatorLayout in this library?
More discusion and explanation is on Stack Overflow.
The text was updated successfully, but these errors were encountered: