Search code examples
androidfloating-action-button

change FloatingActionButton and SubActionButton background color


Is it possible to change the background color of android Floating Action Button and Sub ActionButton when using min APi 16?

I have tried a lot of different situations like:

actionButton.setBackgroundTintList(getResources().getColorStateList(R.color.myColor));

But all say that the min API level is 16 and required is 21.

Is there a way to do it in API level 16 programmatically in the Java file?


Solution

  • To Change the floating action bar color, just write this in your xml

    app:backgroundTint="@color/desired_color"
    

    and in java is

    actionButton.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(context, your color)));