How to change android.support.design.widget.FloatingActionButton color programatically

45 views Asked by At

I have a android.support.design.widget.FloatingActionButton with app:backgroundTint="#3399ff" and android:backgroundTint="@color/white".

I use DrawableCompat.setTintList(DrawableCompat.wrap(floatingActionButton.getContentBackground()), androidBackgroundTintColor);

to change android:backgroundTint="@color/white" but i haven't figured out how to change app:backgroundTint="#3399ff"...

Would you happen to know?

Please note its app:backgroundTint and not android:backgroundTint.

xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
1

There are 1 answers

0
ismail alaoui On

use this :

fab.setBackgroundTintList(ContextCompat.getColorStateList(getApplicationContext(), R.color.purple_200));