android-floating-action-button icon indicating copy to clipboard operation
android-floating-action-button copied to clipboard

How can I change the floating action menu icon?

Open thanos1983 opened this issue 9 years ago • 12 comments

I have tried to add the fab:fab_icon just like on floating buttons, but it does not seem to work. Is there any way to change the background image on the floating menu also, except the buttons?

<com.getbase.floatingactionbutton.FloatingActionsMenu
        android:id="@+id/left_labels"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/mapstyle"
        fab:fab_addButtonColorNormal="@color/white"
        fab:fab_addButtonColorPressed="@color/white_pressed"
        fab:fab_addButtonPlusIconColor="@color/half_black"
        fab:fab_expandDirection="down"
        fab:fab_icon="@drawable/map_marker"
        fab:fab_labelStyle="@style/menu_labels_style"
        fab:fab_labelsPosition="left">

        <com.getbase.floatingactionbutton.FloatingActionButton
            android:id="@+id/alle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            fab:fab_colorNormal="@color/white_transparent"
            fab:fab_colorPressed="@color/white_pressed"
            fab:fab_icon="@drawable/map_marker"
            fab:fab_size="mini"
            fab:fab_title="Alle" />

</com.getbase.floatingactionbutton.FloatingActionsMenu>

Thank you in advance for your time and effort.

thanos1983 avatar Apr 28 '16 08:04 thanos1983

For the icon you just need to set android:src="" filled with a drawable

markvankleef avatar Apr 29 '16 07:04 markvankleef

I did also tried that, but it did not work. :( Thanks for your time and effort though... :D

thanos1983 avatar Apr 29 '16 07:04 thanos1983

+1 to @thanos1983 ...... did u find the answer?

rohitkeshwani07 avatar May 16 '16 03:05 rohitkeshwani07

Hello @rohitkeshwani07,

I do not have a solid solution to my problem but I have created a work around. Because the answer is big to rewrite it I will provide a link in case that someone in the future might have the same problem How to set icon to getbase FloatingActionsMenu. I have also found a solution in order to update the menu icon from the "sub buttons" when they are clicked Change image Floating Action Button Android

I hope this helps somebody else that had the same problem. If you have any queries or my answer is not complete get back to me and I will try to help you.

thanos1983 avatar May 16 '16 07:05 thanos1983

Please use: ... android:src="@android:drawable/ic_menu_share" ... Don't use "fab:icon...", but instead use "android:src..." It works for me👍 X5ibnouf

ibnouf88 avatar May 17 '16 23:05 ibnouf88

Hello @ibnouf88 ,

I just tried it, and for me is not working. I do not know if it it not working because I have modified the library or it does not work generally. But the solution that I have posted it works just fine for me. :D

Maybe someone else can tested and verify that it works.

thanos1983 avatar May 18 '16 14:05 thanos1983

i can confirm that "android:src" has no effect.

Using: 'com.getbase:floatingactionbutton:1.10.1'

Ostkontentitan avatar Jun 09 '16 14:06 Ostkontentitan

Trying this library, you can use custom icon for menu button by using: fab:fab_menuIcon="@drawable/myIcon"

https://github.com/toanvc/FloatingActionMenu-Animation

toanvc avatar Jun 25 '16 07:06 toanvc

if you are using the source not gradle lib then use his changes to the sources.

noman404 avatar Aug 26 '16 06:08 noman404

I am also not getting menu icon using android:src="@drawable/*" and using com.getbase:floatingactionbutton:1.10.1 included in gradle as of @Ostkontentitan

ghost avatar Apr 04 '17 18:04 ghost

For the menu icons I ended up doing it in Java:

FloatingActionButton btn = view.findViewById(R.id.buttonID);
btn.setIcon(R.drawable.myimage);

I also downloaded the library to use in my project locally, not sure if that makes a difference.

williamsiuhang avatar Sep 27 '17 16:09 williamsiuhang

using this library com.github.clans.fab.FloatingActionMenu

app:menu_icon="@drawable/ic_share" above solution worked for me.

akshkdm avatar Sep 11 '18 14:09 akshkdm