Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change image Floating Action Button Android

I used this library https://github.com/futuresimple/android-floating-action-button. How can I change the image of the main button? I want to change the button image right after selecting one of the smaller buttons.

like image 218
pippo10 Avatar asked May 26 '15 10:05

pippo10


People also ask

How do I change the floating action button image?

Add the floating action button to your layout The size of the FAB, using the app:fabSize attribute or the setSize() method. The ripple color of the FAB, using the app:rippleColor attribute or the setRippleColor() method. The FAB icon, using the android:src attribute or the setImageDrawable() method.

How do I change the shape of the floating action button on Android?

To change the shape of the Floating action button: You can use the shape property of FloatingActionButton() widget class. Implement BeveledRectangleBorder( ) on this property. The output will be a square floating action button, increase the border-radius value to make a circular type shape.


1 Answers

From https://developer.android.com/reference/android/support/design/widget/FloatingActionButton.html

As this class descends from ImageView, you can control the icon which is displayed via setImageDrawable(Drawable).

Or you can use setImageResource():

fab.setImageResource(R.drawable.ic_shopping_cart_white); 
like image 57
Alex Bravo Avatar answered Sep 21 '22 00:09

Alex Bravo