如何从ImageView获取backgroundColor?我的代码示例 ImageView imageViewNote = (ImageView) findViewById(R.id.chooseColorEdit);
如何从ImageView获取backgroundColor
感谢
如何从ImageView获取backgroundColor?我的代码示例 ImageView imageViewNote = (ImageView) findViewById(R.id.chooseColorEdit);
如何从ImageView获取backgroundColor
感谢
你可以得到类似的背景下面的代码
Drawable bgDrawable = imageViewNote.getBackground();
试试这个(你的背景实际上是一种颜色它只能在情况下,否则,你真的没有“背景”颜色“):
Drawable background = userNameTextView.getBackground();
if (background instanceof ColorDrawable) {
int color = ((ColorDrawable) background).getColor();
// Use color here
}
尝试获得的ImageView的ColorDrawable?