I would like to create the
Layout
that comes out in the attached image but I am not able, or it moves or I overlap and I do not fit perfect playing with width and height. I would like to have a horizontal listview
, which I will put inside a LinerLayout
which is what is in red and the 4 rectangles in orange (which I have tried to be Relative
will be buttons or imagebutton
that I will put inside, but I have not been able to do it.
I have tried to put FrameLayout
and inside it I can already play a little more with the Relative
but I always place myself in the upper left corner and there is no way to move them to the right or down and I would like everything to be square. Someone who has done something similar or similar?
My code but I can't achieve my image with orange and red rectangles.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:stretchColumns="1">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="111dp"
android:orientation="horizontal"></LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="173dp">
</RelativeLayout>
</FrameLayout>
</RelativeLayout>
Try this 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"
android:padding="5dp"
android:weightSum="5">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/border"
android:orientation="horizontal">
<ListView
android:id="@+id/list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="horizontal"
android:weightSum="2">
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/border"
android:src="@mipmap/ic_launcher" />
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/border"
android:src="@mipmap/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="horizontal"
android:weightSum="2">
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/border"
android:src="@mipmap/ic_launcher" />
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/border"
android:src="@mipmap/ic_launcher" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
in res/drawable/border.xml
<?xml version="1.0" encoding="utf-8"?><!-- res/drawable/rounded_edittext.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle">
<stroke
android:width="3dp"
android:color="#000000" />
<corners android:radius="0dp" />
</shape>
Output