【发布时间】:2015-11-02 10:47:19
【问题描述】:
我正在尝试使用 androids material design 的调色板功能,但我在应用它时遇到了一些麻烦。
我已成功生成调色板,现在我正尝试将调色板传递给应用它的函数。
我遇到的问题是,当我将调色板传递给 applyPalette 函数时,没有任何方法像 palette.getDarkMutedColor().getRgb() , palette.getVibrantColor().getRgb() 被填充调色板中的值。
除了将调色板传递给函数之外,我所遵循的教程没有提及其他任何内容,并且这样做会填充方法
这是生成器函数和应用函数,任何人都可以看到为什么这不起作用吗?
代码
private void colorize(Bitmap photo) {
Palette palette = new Palette.Builder(photo).generate();
applyPalette(palette);
}
private void applyPalette(Palette palette) {
getWindow().setBackgroundDrawable(new ColorDrawable(palette.getDarkMutedColor().getRgb()));
TextView titleView = (TextView) findViewById(R.id.title);
titleView.setTextColor(palette.getVibrantColor().getRgb());
TextView descriptionView = (TextView) findViewById(R.id.description);
descriptionView.setTextColor(palette.getLightVibrantColor().getRgb());
colorRipple(R.id.info, palette.getDarkMutedColor().getRgb(),
palette.getDarkVibrantColor().getRgb());
colorRipple(R.id.star, palette.getMutedColor().getRgb(),
palette.getVibrantColor().getRgb());
View infoView = findViewById(R.id.information_container);
infoView.setBackgroundColor(palette.getLightMutedColor().getRgb());
AnimatedPathView star = (AnimatedPathView) findViewById(R.id.star_container);
star.setFillColor(palette.getVibrantColor().getRgb());
star.setStrokeColor(palette.getLightVibrantColor().getRgb());
}
【问题讨论】:
-
尝试移除 getRgb() 函数。
-
不,没有帮助仍然有同样的错误
-
当您说颜色功能“不起作用”时,请澄清您的意思。
-
我收到一个错误,在每个语句下划线
DarkMutedColor (int) in Palette cannot be applied to 0 -
您使用的是哪个版本的 Palette(例如 21.0.0)?