Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Layout with weights takes space even after setting visibility to gone

I have a horizontal LinearLayout with 4 child LinearLayouts, each having a weight of 1. With all of the 4 children visible, the screen is nicely divided in a 25% ratio for all 4. But when I change the visibility of 1 child to gone (statically, in the XML), the layout still takes space (as if invisible) and the other 3 layouts keep on sharing 25% each; rather than 33% each.

I have ensured proper weights, with layout_height of 0dp. I also tried setting visibility to gone for all the children of the LinearLayout I want to hide.

What other things can I try ?

like image 707
dev Avatar asked Jan 23 '26 03:01

dev


1 Answers

Silly mistake ! I had set the layout_width of parent LinearLayout as wrap_content. Changing it to match_parent worked :)

like image 59
dev Avatar answered Jan 25 '26 17:01

dev



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!