I am trying to add background image which has linear layout as a root layout
[Look hierarchy diagram for reference.]
I have tried using Relative Layout as a root layout but it overlap the nested linear layouts.
While with linear layout as a root layout it displays only at the bottom.
XML Code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/line1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:textSize="26sp"
android:textStyle="bold"
android:text="Team A" />
<TextView
android:id="@+id/team_a_score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:text="0"
android:textSize="40sp"
android:textStyle="bold"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:onClick="add3forA"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="+3 Points" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:onClick="add2forA"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="+2 Points" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:onClick="add1forA"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="Free Throw" />
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:textSize="26sp"
android:textStyle="bold"
android:text="Team B" />
<TextView
android:id="@+id/team_b_score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textSize="40sp"
android:textStyle="bold"
android:text="0" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:onClick="add3forB"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="+3 Points" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:onClick="add2forB"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="+2 Points" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:onClick="add1forB"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="Free Throw" />
</LinearLayout>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reset"
android:layout_gravity="center_horizontal"
android:layout_marginTop="40dp"
android:onClick="reset"/>
</LinearLayout>
View Hierarchy Diagram
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…