I am trying to make a screen, preferably with XML only, to look like this:
I followed this approach, but using FrameLayout I only have the option to position the "orange" view using layout_gravity
, and as I try to explain in the image, I don't know the layouts' height, because both measure with layout_weight.
My layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="onit.radiolisten.MainActivity">
<FrameLayout
android:id="@+id/layout_container_activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- TOP LAYOUT, THE GREEN ONE ON THE IMAGE -->
<LinearLayout
android:id="@+id/layout_top_activity_main"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="2"
android:background="@color/colorPrimary"
android:orientation="vertical"></LinearLayout>
<!-- BOTTOM LAYOUT, THE BLUE ONE ON THE IMAGE -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#e6e6e6">
</RelativeLayout>
</LinearLayout>
<!-- THIS IS THE IMAGE I WANT TO POSITION -->
<ImageView
android:id="@+id/btn_play_radio"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:src="@drawable/play_icon" />
</FrameLayout>
</LinearLayout>
Can this be done with XML only?