I want to create a layout like this.layout
The big rectangle will be divided into smaller rectangles (with rounded corners) shown in yellow. I want to place my items like image in the smaller rectangles. I do not know what to search for to get related links.
I do not know that is why asking. I think this is a place for experts only.
yellow rectangles are not a problem, but how to create that additional layout inside another layout. Like if I declare a layout inside another layout, it will take the whole space. How to get a border of rounded corners that leaves space at 4 sides.
I was adviced to use shape xml. But I want a layout where I can place child components and not a drawable.
I made a code. I want to know if it is the right way to do?
CODE:
drawable/round_corner_rectangle.xml:
<?xml version ="1.0" encoding ="utf-8"?><!-- Learn More about how to use App Actions: https://developer.android.com/guide/actions/index.html -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomRightRadius="10dp"
android:topRightRadius="10dp"
android:topLeftRadius="10dp"
android:bottomLeftRadius="10dp"
/>
<gradient
android:angle="45"
android:endColor="#0a91ee"
android:gradientRadius="41dp"
android:startColor="#0f29eeaa"
android:type="linear" />
<!--android:centerX="float"
android:centerY="float"-->
<!--If your shape requires only one solid color-->
<!--<solid
android:color="#FFFFFF" />-->
<size
android:width="482dp"
android:height="200dp" />
<!--Use android:dashWidth="2dp" and android:dashGap="2dp"
to add dashes to your stroke-->
<stroke
android:width="2dp"
android:color="#FFFFFF" />
<!--If you want to add padding-->
<!-- <padding
android:left="10dp"
android:top="20dp"
android:right="40dp"
android:bottom="8dp" />-->
</shape>
drawable/drawii.xml:
<?xml version ="1.0" encoding ="utf-8"?><!-- Learn More about how to use App Actions: https://developer.android.com/guide/actions/index.html -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomRightRadius="10dp"
android:radius="40dp" />
<gradient
android:angle="45"
android:endColor="#01f1fa"
android:gradientRadius="41dp"
android:startColor="#0189ff"
android:type="linear" />
<!--android:centerX="float"
android:centerY="float"-->
<!--If your shape requires only one solid color-->
<!--<solid
android:color="#FFFFFF" />-->
<size
android:width="82dp"
android:height="82dp" />
<!--Use android:dashWidth="2dp" and android:dashGap="2dp"
to add dashes to your stroke-->
<stroke
android:width="2dp"
android:color="#FFFFFF" />
<!--If you want to add padding-->
<!-- <padding
android:left="10dp"
android:top="20dp"
android:right="40dp"
android:bottom="8dp" />-->
</shape>
layout/activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent" android:orientation="vertical"
android:gravity="fill_vertical" android:layout_margin="10dp"
>
<!--android:padding="10dp"-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent" android:orientation="horizontal"
android:gravity="fill_horizontal"
android:background="@drawable/round_corner_rectangle"
android:layout_margin="0.5dp"
>
<!--android:layout_margin="20dp"-->
<ImageButton
android:id="@+id/imageButtonGenerateBulk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="25dp"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Generate Qr Code"
android:textStyle="bold"
android:layout_alignEnd="@+id/tv_question"
android:layout_alignRight="@+id/tv_question"
android:background="#00ffffff"
android:src="@drawable/drawii"
android:layout_weight="1"/>
<ImageButton
android:id="@+id/imageButtonGenerateBulk2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="25dp"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Generate Qr Code"
android:textStyle="bold"
android:layout_alignEnd="@+id/tv_question"
android:layout_alignRight="@+id/tv_question"
android:background="#00ffffff"
android:src="@drawable/drawii"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent" android:orientation="horizontal"
android:gravity="fill_horizontal"
android:background="@drawable/round_corner_rectangle"
android:layout_margin="0.5dp"
>
<!--android:layout_margin="20dp"-->
<ImageButton
android:id="@+id/imageButtonGenerateBulk3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="25dp"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Generate Qr Code"
android:textStyle="bold"
android:layout_alignEnd="@+id/tv_question"
android:layout_alignRight="@+id/tv_question"
android:background="#00ffffff"
android:src="@drawable/drawii"
android:layout_weight="1"/>
<ImageButton
android:id="@+id/imageButtonGenerateBulk4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="25dp"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Generate Qr Code"
android:textStyle="bold"
android:layout_alignEnd="@+id/tv_question"
android:layout_alignRight="@+id/tv_question"
android:background="#00ffffff"
android:src="@drawable/drawii"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent" android:orientation="horizontal"
android:gravity="fill_horizontal"
android:background="@drawable/round_corner_rectangle"
android:layout_margin="0.5dp"
>
<!--android:layout_margin="20dp"-->
<ImageButton
android:id="@+id/imageButtonGenerateBulk5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="25dp"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Generate Qr Code"
android:textStyle="bold"
android:layout_alignEnd="@+id/tv_question"
android:layout_alignRight="@+id/tv_question"
android:b
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…