[英]How to get appropriate title text color with palette
This is what happened when I Used 这是我使用时发生的情况
I want to get compliment text color from palette object 我想从调色板对象获取赞美文字颜色
I tried this, but it didn't work out as supposed to be palette.getVibrantSwatch().getTitleTextColor(); 我尝试了一下,但是没有成功,因为应该是palette.getVibrantSwatch()。getTitleTextColor();。
Please help me in showing right Way of Obtaining text color Using Palette 请帮助我显示使用调色板获取文本颜色的正确方法
It takes some time to generate colors from supplied resource, that is why you should use Pallet asynchronously. 从提供的资源生成颜色需要花费一些时间,这就是为什么您应该异步使用Pallet的原因。
Bitmap bm = BitmapFactory.decodeResource(getResources(), VersionData.getOsDrawable(osVersion)); 位图bm = BitmapFactory.decodeResource(getResources(),VersionData.getOsDrawable(osVersion));
Palette.PaletteAsyncListener listener = new Palette.PaletteAsyncListener() {
public void onGenerated(Palette palette) {
Log.d("Palette", "Palette has been generated");
TextView tv1 = (TextView) findViewById(R.id.tv1);
TextView tv2 = (TextView) findViewById(R.id.tv2);
// use initialized Pallet here tv1.setBackgroundColor(palette.getVibrantColor(0x000000));
tv2.setBackgroundColor(palette.getVibrantColor(0x000000)); tv2.setBackgroundColor(palette.getVibrantColor(0x000000));
//Noticed the Expanded white doesn't show everywhere, use Palette to fix this
collapsingToolbar.setExpandedTitleColor(palette.getVibrantColor(0x000000));
}
};
// Start this Async, because it takes some time to generate
Palette.from(bm).generate(listener);
There is a excellent Material Design sample project https://github.com/mwolfson/android-historian 有一个出色的Material Design示例项目https://github.com/mwolfson/android-historian
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.