使用我的图像调色板更改浮动操作按钮的背景颜色

时间:2017-02-16 07:57:37

标签: android floating-action-button

这是我用来从调色板中检索颜色的代码。我能够获得颜色但无法设置为浮动动作按钮的背景颜色。

Palette.Swatch vibrantSwatch = palette.getDarkVibrantSwatch();
Palette.Swatch vibrantSwatch2 = palette.getLightVibrantSwatch();

if ( vibrantSwatch != null && vibrantSwatch2 != null) {
    //fb represents my floating action button
    fb.setBackgroundTintList(ColorStateList.valueOf(vibrantSwatch2.getRgb()));
}

1 个答案:

答案 0 :(得分:0)

我认为你应该使用

getRGB(int x,int y)

而不是getRGB()。

它返回默认RGB颜色模型(TYPE_INT_ARGB)和默认sRGB颜色空间中的整数像素。

相关问题