Skip to content Skip to sidebar Skip to footer

[android]how To Get 4 Buttons At The Bottom And Each 2 Button Is Beside Each Other

I find majority teaching online is about 2 button beside each other but I couldnt obtain the arrangement wanted as in the image. When I put in the relativelayout, all the button ov

Solution 1:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/billTV"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.55"
        android:text="TextView" />

    <TextView
        android:id="@+id/total"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="TextView" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="bottom"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/backB"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Back" />

        <Button
            android:id="@+id/payB"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Pay" />
    </LinearLayout>

</LinearLayout>

Try some thing like this.


Solution 2:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/billTV"
                android:layout_width="fill_parent"
                android:layout_height="394dp"
                android:text="TextView" />
        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/total"
                android:layout_width="fill_parent"
                android:layout_height="32dp"
                android:text="TextView" />

        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <Button
                android:id="@+id/backB"
                android:layout_width="106dp"
                android:layout_height="wrap_content"
                android:text="Back" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="right"
            android:orientation="vertical" >

            <Button
                android:id="@+id/payB"
                android:layout_width="120dp"
                android:layout_height="wrap_content"
                android:text="Pay" />

        </LinearLayout>

    </LinearLayout>

</LinearLayout>

try this


Post a Comment for "[android]how To Get 4 Buttons At The Bottom And Each 2 Button Is Beside Each Other"