Getting the background color of an ImageView
问题 I have a plain ImageView object colorSquare . It is straightforward to set the color of the object by calling. colorSquare.setBackgroundColor(color); But how do I do the reverse, i.e. retrieve the color of the ImageView background? 回答1: What u can do is get ColorDrawable from ImageView. ColorDrawable drawable = (ColorDrawable) colorSquare.getBackground(); now drawable.getColor() will give u the Color. This will work only if u have set the Color or else u will get ClassCastException 回答2: