Palette可以提取的颜色:
Vibrant (有活力的)
Vibrant dark(有活力的 暗色)
Vibrant light(有活力的 亮色)
Muted (柔和的)
Muted dark(柔和的 暗色)
Muted light(柔和的 亮色)
compile 'com.android.support:palette-v7:25.3.1'
// Synchronous
Palette p = Palette.from(bitmap).generate();
// Asynchronous
Palette.from(bitmap).generate(new PaletteAsyncListener() {
public void onGenerated(Palette p) {
// Use generated instance
}
});
var bitmap: Bitmap = BitmapFactory.decodeResource(resources, R.mipmap.img)
Palette.from(bitmap).generate(object : Palette.PaletteAsyncListener {
override fun onGenerated(palette: Palette?) {
if (palette != null) {
var vibrant = palette!!.vibrantSwatch//有活力的
var vibrantDark = palette!!.darkVibrantSwatch//有活力的,暗色
var vibrantLight = palette!!.lightVibrantSwatch//有活力的,亮色
var muted = palette!!.mutedSwatch//柔和的
var mutedDark = palette!!.darkMutedSwatch//柔和的,暗色
var mutedLight = palette!!.lightMutedSwatch//柔和的,亮色
var vibrantColor = muted!!.rgb
textView1.setBackgroundColor(vibrantColor)
}
}
网友评论