how can I change the background of an ImageView from java? I have an ImageView and at a certain point I need to change the image that it displays (set in the styles). I tried to do it like this:
placeHolder.setImageDrawable(myDrawb);
but it looks like the old image remains there and it is partially covered but the new one (which in my case has different shape).
hope you guys can help!
cheers
You don’t need to touch the XML to use src instead of background!
An ImageView can display two drawables! One in the background and other in the foreground.
It seems that you are always changing the background image.
Instead of
setBackgroundResource(resId)usesetImageResource(resId)to change the foreground image!