3

How can I have a layout where there is a view occupying most of the top of the screen and a bottom bar below it in the bottom of the screen without setting size for top view directly?

Fixpoint
  • 9,619
  • 17
  • 59
  • 78
  • see this for a native bottom bar: http://stackoverflow.com/questions/36019986/which-view-should-be-used-for-new-material-design-bottom-navigation/42119958#42119958 – Fartab Feb 08 '17 at 17:46

1 Answers1

10

You can set the top View's android:layout_weight set to "1", then you can set your bottom View's height and the top View will take up all remaining space. For example:

<LinearLayout android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_weight="1" />
<LinearLayout android:layout_width="fill_parent"
    android:layout_height="25dip" />

(Of course, if there is content in the bottom View, you can just set the height to "wrap_content" and have it set its own size based on its contents.)

Dan Lew
  • 85,990
  • 32
  • 182
  • 176