我正在尝试使用Android的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());
}
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.google.android.gms:play-services:6.5.87' }
我是否应该使用另一个来处理调色板? - Hayes121