问题
I am using this library for floating action button
https://github.com/futuresimple/android-floating-action-button
If anyone is aware about it, we know that we can change the background color of floating action menu with this line in xml :
fab:fab_addButtonColorNormal="@color/floating_action_menu"
Is there a way to do so programmatically??
floatingmenu.setBackgroundColor(color) doesnt work......
回答1:
It looks like FloatingActionsMenu has no getter/setter for this.
To get this feature you can fork the project and add getter for mAddButton
member of FloatingActionsMenu
class:
AddFloatingActionButton getAddButton(){
return mAddButton;
}
Then you will be able to call methods of FloatingActionButton
class :
floatingmenu.getAddButton().setColorNormal(...);
回答2:
I got one solution
Add this method in FloatingActionsMenu class :
public void setNormalColor(int color) {
mAddButtonColorNormal = color;
removeView(mAddButton);
createAddButton(myContext);
}
It's works for me
来源:https://stackoverflow.com/questions/30099725/how-to-change-background-color-of-floating-action-menu