【问题标题】:How to change android.support.design.widget.FloatingActionButton color programatically如何以编程方式更改 android.support.design.widget.FloatingActionButton 颜色
【发布时间】:2019-05-24 14:42:03
【问题描述】:

我有一个 android.support.design.widget.FloatingActionButtonapp:backgroundTint="#3399ff"android:backgroundTint="@color/white"

我用DrawableCompat.setTintList(DrawableCompat.wrap(floatingActionButton.getContentBackground()), androidBackgroundTintColor);

要更改android:backgroundTint="@color/white",但我还没弄清楚如何更改app:backgroundTint="#3399ff"...

你会知道吗?

请注意它的 app:backgroundTint 而不是 android:backgroundTint

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

【问题讨论】:

    标签: android background floating-action-button android-support-design


    【解决方案1】:

    使用这个:

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

    【讨论】:

      猜你喜欢
      • 2016-07-03
      • 2015-12-06
      • 2021-03-31
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 2023-01-30
      • 2010-12-21
      相关资源
      最近更新 更多