Android - Removing an ImageView from a RelativeLayout



How can I remove an ImageView from a RelativeLayout? For some reason RelativeLayout.removeView(iv); doesn't work. I'm creating the ImageView programmatically like this:


final ImageView iv = new ImageView(MainActivity.this); But this doesn't work.


I don't want to use iv.setVisibility(View.GONE); because this doesn't really remove the image, it just sets the visibility.


Why isn't this working? Is there any alternative?


No comments:

Post a Comment