androidlistviewheightandroid-linearlayoutandroid-wrap-content

Android height wrap_content with fix ratio


My XML file has a LinearLayout containing two ListView with android:height="wrap_content". However, when one of the ListView has too much contents, it pushes another ListView and eat up its space. What can I do to make it stops pushing at certain height? I've tried adding layout-weight or maxHeight but it doesn't help.


Solution

  • I solved it by doing it programmatically. It seems XML doesn't give much control for dynamic height. I added onLayoutChangedListener to both ListView to detect height change and add height control logic in the listener.