开发者

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


If possible paste your xml file.

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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜