layout with top bar, bottom bar & remaining space content view
android, android-layout
Solution
You can use android:layout_weight property to achieve that, but your parent container has to be a LinearLayout, in my example I'm using just LinearLayout as children of the parent view but you can use another type of View:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:id="@+id/layout_a"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
<LinearLayout
android:id="@+id/layout_b"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</LinearLayout>
<LinearLayout
android:id="@+id/layout_c"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
</LinearLayout>
If you're curious and wanna know how it works... here is the explanation, good luck :)
Problem
I'm getting crazy with the android views. I want a layout with a bar on top (A) and one bar one the bottom (C) of my app with `height="wrap_content"`. The full remaining space in the middle (B) should be the content area with another Layout or `TextView` or whatever. But i can't get this to work. I tried a lot with the layouts, but when i do `android:layout_height="match_parent"` to B, C disappears. Any ideas? Thanks in advance