I have an XML layout where I nested a FrameLayout within a LinearLayout and attempted to stack a sibling viewing group on top of the FrameLayout. It does not show the sibling viewing group at all, but just the FrameLayout. I wanted to please get some help in understanding why replacing the root ViewGroup to a RelativeLayout produces an expected output.
Here is the Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mainFrameLayout"
android:background="#787878"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/ImageView01"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:src="@drawable/download"
android:adjustViewBounds="true"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000"
android:textSize="40sp"
android:text="Top text" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="right"
android:text="bottom_text"
android:textColor="#fff"
android:textSize="50sp" />
</LinearLayout>
</LinearLayout>
I only see the FrameLayout by itself filling the screen. When I change the root ViewGroup to a RelativeLayout defined with a layout_height and layout_width to "match_parent", I get my expected output where the ImageView and both TextViews show on top of the FrameLayout. I am confused on how that made it work because I didn't specify any RelativeLayout parameters to the child ViewGroups/View like "bottomof" or "topof".
Is there a resizing propery or weight distribution that RelativeLayout has that LinearLayout does not? I have been looking online, but unfortunately have not found an answer.
Thank you!