Reputation: 33
I have two linear layouts e.g. L1 and L2. I put them on a single activity. Outside these two layouts, I have a radio button from which I'm controlling visibility. At a time only 1 should be visible. It perfectly working but the problem is,
Two linear layouts are stacked over each other. So when I invisible the upper layout(L1) then it shows white space in that area.
So the L1 gets invisible but space is still occupied by itself.
I want to take that area from L1 so that L2 replaces it.
[Note: This is just a concept so I thought the XML code is not required. But still, if you need I will update it]
Upvotes: 0
Views: 63
Reputation: 1353
When you turn the visibility to invisible
, you can't see the layout but it will still there and occupying the space. It is similar to the layout.setAlpha(0f);
. When you use setAlpha(0f);
, the user can interact with all the views inside that layout i.e, Button
inside layout will not visible but can be clicked. While setVisibility(View.INVISIBLE);
doesn't allow to do so.
When you turn the visibility to gone
, the layout becomes not visible (act as height and width become 0
). But it stills present in its parent view. It doesn't mean that it will be removed from the parent layout.
Upvotes: 1
Reputation: 4007
Instead of setting the visibility to invisible
, set it at gone
. The different is that, in gone
mode, components are not part of the visual tree anymore
Upvotes: 2