如何从ImageView中获取背景彩色?我的代码示例
ImageView imageViewNote = (ImageView) findViewById(R.id.chooseColorEdit);
谢谢
您可以从下面的代码
中获得背景Drawable bgDrawable = imageViewNote.getBackground();
尝试一下(仅在您的背景实际上是一种颜色的情况下起作用,否则,您实际上没有"背景"颜色"(:
Drawable background = userNameTextView.getBackground();
if (background instanceof ColorDrawable) {
int color = ((ColorDrawable) background).getColor();
// Use color here
}
尝试获取图像视图的colordraw?