Reputation: 3807
I have a layout with tho views, A and B,
___
|A|
|B|
---
A can have very varying height. I want B to have ParentHeight-A.height, and would like to this via xml (I know I can resize them programmatically, but hope to avoid it).
How can I achieve this with the Android layout system?
Upvotes: 3
Views: 735
Reputation: 20553
Use a LinearLayout
and set B's layout_weight
property to 1. It will occupy all the space that is left after A occupies the space it needs.
Upvotes: 3
Reputation: 57306
This is absolutely basic layout stuff. I suggest you read up about LinearLayout
and width/height specifications. Generally speaking, your layout will be something like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View android:id="@+id/A
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<View android:id="@+id/B
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Upvotes: 2