How to programmatically set backgroundTint of FloatingActionButton with ColorStateList?
use this:
fab.setBackgroundTintList(ContextCompat.getColorStateList(getApplicationContext(), R.color.purple_200));
Cheers!
Since setBackgroundTintList
is only supported in API 21+ you can use ViewCompat.
ViewCompat.setBackgroundTintList(
fab,
ContextCompat.getColorStateList(
getApplicationContext(),
R.color.purple_200
)
);