Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 465
Arun Avatar asked Apr 17 '26 05:04

Arun


2 Answers

If possible paste your xml file.

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

like image 58
Harshad Avatar answered Apr 18 '26 18:04

Harshad


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

like image 30
hfitzwater Avatar answered Apr 18 '26 19:04

hfitzwater



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!