Search code examples
androidandroid-layoutexpandableandroid-layout-weight

How to set Weight to make bottom view occupy remaining space Android


I want to model my layout screen in the following 2 parts.

  1. Basic Information related Linear layout with expandable view initially 20 % of screen height.
  2. Bottom List view occupy Remaining Space.

But When the top view is expanded then i want to make it height upto 50 % and the bottom listview should start then after.

I have attached image for reference.

I have tried setting the layout_weight of top and bottom layout. But not able to find out exact solution. May be i am missing some points.

Let me know if you need more information from my end.

Thanks in Advance.

regards, Rakesh

Layout requirement


Solution

  • Try to remove the current weight from the top view and in the listview set android:layout_weight="1" and android:layout_height="0dp". This makes the ListView to take whatever height left in the screen.