I have a problem with FrameLayout. I want to create FrameLayout which will have it's first child's height and the second child will get it's parent's height(100dp in this example). But what I get is the FrameLayout is filling the screen(match_parent).
Here is my xml.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<View
android:layout_width="match_parent"
android:layout_height="100dp" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
How can I make FrameLayout to be as big as it's first child and the second child as big as it's parent? Do I need to use different parent?
Using RelativeLayout will surely serve you what you are trying to achieve:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<View
android:id="@+id/view_id_1"
android:layout_width="match_parent"
android:layout_height="100dp" />
<View
android:id="@+id/view_id_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/view_id_1"
android:layout_alignTop="@+id/view_id_1" />
</RelativeLayout>
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With