简体   繁体   中英

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

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"

用这个 :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM