Clans / FloatingActionButton

Android Floating Action Button based on Material Design specification
Apache License 2.0
5.22k stars 1.13k forks source link

FloatingActionButton label text color #408

Open GregoryIwanek opened 7 years ago

GregoryIwanek commented 7 years ago

Hi. I have floating action menu with couple of floating action buttons and labels. When I initiate module with menu I need to set colors to some labels ( which button, differes between occurs of module initiation, so it can't be hardcoded).

Is there any possibility to set FAB's label text color programmatically on Java side? Fab button has method fab.setLabelTextColor(int color), but trying to call this results in java.lang.NullPointerException: Attempt to invoke virtual method 'void com.github.clans.fab.Label.setTextColor(int)' on a null object reference at com.github.clans.fab.FloatingActionButton.setLabelTextColor(FloatingActionButton.java:1314)

I could iterate through all views inside fab menu and with method "xxx instanceof Label" get access to Label views, and modify them directly but it's unefficient; Can floating button color parameters be set from java code? Or only in xml?

Thanks in advance.

baggednismo commented 7 years ago

Of course they can. You are using the correct method to do this. Not sure what your code line is but here is an example that I just tested and its working: fab.setLabelTextColor(Color.BLACK);

I personally dont change the label color but I tested this during onCreateView of my fragment where I programmatically set the button size and image.

screenshot from 2017-08-02 14-58-40

narendra8 commented 6 years ago

Great it's working.

rpinto18 commented 6 years ago

Color labeñ app:menu_labels_textColor="#FFB098"

Paryszek commented 6 years ago

change fab for app prefix in xml schema