I have a hidden image button in one of my xmls layouts, with a background set to a drawable image. I set the visibility to invisible, as I only want the image to display every once in a while. The problem is, even if the drawable isn't shown, the image button still takes us space - Is there a way to hide the background image, and make it's dimensions 0 until I call on it to be shown in my main class?
Edit: So in my xml, how would I write that?
<ImageButton android:id="@+id/myimage" android:visibility="invisible"
All views, including ImageButton, inherit from android.view.View, so they all have a visibility attribute that can be set. Instead of setting the visibility of the drawable resource, set it on the ImageButton.