美文网首页Android_MaterialDesign我爱编程
MaterialDesign系列文章(三)Palette库来获取

MaterialDesign系列文章(三)Palette库来获取

作者: 笔墨Android | 来源:发表于2017-11-06 23:33 被阅读74次

不怕跌倒,所以飞翔

Color(Palette库来获取图片的主要色彩)

  • Vibrant (有活力)
  • Vibrant dark(有活力 暗色)
  • Vibrant light(有活力 亮色)
  • Muted (柔和)
  • Muted dark(柔和 暗色)
  • Muted light(柔和 亮色)
//目标bitmap,代码片段
        Bitmap bm = BitmapFactory.decodeResource(getResources(),
                R.drawable.kale);
        Palette palette = Palette.generate(bm);
        if (palette.getLightVibrantSwatch() != null) {
            //得到不同的样本,设置给imageview进行显示
            iv.setBackgroundColor(palette.getLightVibrantSwatch().getRgb());
            iv1.setBackgroundColor(palette.getDarkVibrantSwatch().getRgb());
            iv2.setBackgroundColor(palette.getLightMutedSwatch().getRgb());
            iv3.setBackgroundColor(palette.getDarkMutedSwatch().getRgb());
        }

通过这个类,我们可以很方便的取得相应的颜色值,通过代码动态设置.


这一系列文章的地址,希望对大家有帮助

项目地址

相关文章

网友评论

    本文标题:MaterialDesign系列文章(三)Palette库来获取

    本文链接:https://www.haomeiwen.com/subject/ztnrmxtx.html