Circle ImageView的颜色

时间:2017-04-21 20:44:20

标签: android

我创建了圆形ImageView,下一个代码

ImageView colorView = (ImageView) findViewById(R.id.chooseColorEdit);
colorView.setBackgroundColor(Color.MAGENTA);
Drawable drawable = getResources().getDrawable(R.drawable.circle);
drawable.setColorFilter(Color.GRAY, PorterDuff.Mode.SRC);
colorView.setBackground(drawable);

我如何从imageView获取颜色?

2 个答案:

答案 0 :(得分:0)

你可以获得如下代码的颜色

Drawable background = colorView.getBackground();
if (background instanceof ColorDrawable) {
   Color color = ((ColorDrawable) background).getColor();
 }

答案 1 :(得分:0)

1。ImageView获取ColorDrawable colorDrawable = (ColorDrawable) colorView.getBackground();

color

2。使用

获取colorDrawable.getColor();
Could not provision topic 'queue///EMB_DEV_QUEUE'