Arun
Arun

Reputation: 3077

Height of objects not reducing when objects are hidden - Android layouts

I have a LinearLayout containing two TextViews. I want the height of the LinearLayout to be fluid. When one of them is hidden, it should collapse to the height of the only visible Textview. I have specified the layout_height of the LinearLayout to "wrap_content" and set the visibility to invisible in the XML file. When I run the app, the layout is still the original size. Any ideas?

Thanks

Upvotes: 2

Views: 2903

Answers (3)

Harshad
Harshad

Reputation: 8014

If possible paste your xml file.

And insted of setting visibility to invisible use setVisibility(View.GONE);

Upvotes: 13

JiangCat
JiangCat

Reputation: 125

Unless you have the actual code present, it's really hard to tell a reason causing this issue. For general ideas, CSS style 'hidden' doesn't actually 'remove it' from the parent object displaying area. Instead, try display:none for what you are looking for.

Upvotes: 0

hfitzwater
hfitzwater

Reputation: 544

If I understand your question correctly, what you want to do is change the visibility to gone. A "gone" view will cause the others to behave as if it had never been added.

Reference: http://developer.android.com/reference/android/view/View.html#attr_android:visibility

Upvotes: 2

Related Questions