Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put a button between two layouts

I want to put a normal button between two layouts as showing in image.

I do not want to use floating button and coordinator layout.

Is it possible by relative layout ?

Demo Image no image description

I am using following xml file to do it.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="10" >

    <fragment
        android:id="@+id/mapForPlannedRide"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="3.5" />

    <LinearLayout
        android:id="@+id/planned_detail_layout"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="6.5"
        android:background="@color/text_white"
        android:orientation="vertical"
        android:weightSum="10" >

        <LinearLayout
            android:id="@+id/departure_layout"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="2.5"
            android:gravity="center_vertical"
            android:orientation="horizontal"
            android:paddingLeft="20dp"
            android:paddingRight="20dp" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/passenger" />

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:paddingLeft="5dp" >

                <TextView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/departure"
                    android:textSize="@dimen/text_size17sp" />

                <TextView
                    android:id="@+id/departure"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="dfg ddfghd dfdg"
                    android:textSize="@dimen/text_size14sp" />
            </LinearLayout>
        </LinearLayout>

        <View
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight=".03"
            android:background="@color/line_color" />

        <LinearLayout
            android:id="@+id/destination_layout"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="2.5"
            android:gravity="center_vertical"
            android:orientation="horizontal"
            android:paddingLeft="20dp"
            android:paddingRight="20dp" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/passenger" />

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:paddingLeft="5dp" >

                <TextView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/destination"
                    android:textSize="@dimen/text_size17sp" />

                <TextView
                    android:id="@+id/destination"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Dilshad Garden Delhi"
                    android:textSize="@dimen/text_size14sp" />
            </LinearLayout>
        </LinearLayout>

        <View
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight=".03"
            android:background="@color/line_color" />

        <LinearLayout
            android:id="@+id/date_time_layout"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="1.5"
            android:gravity="center_vertical"
            android:orientation="horizontal"
            android:paddingLeft="20dp"
            android:paddingRight="20dp" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/passenger" />

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:paddingLeft="5dp" >

                <TextView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/date_time"
                    android:textSize="@dimen/text_size17sp" />

                <TextView
                    android:id="@+id/date_time"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="10:00 a.m."
                    android:textSize="@dimen/text_size14sp" />
            </LinearLayout>
        </LinearLayout>

        <View
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight=".03"
            android:background="@color/line_color" />

        <LinearLayout
            android:id="@+id/chosen_vehicle_layout"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="1.5"
            android:gravity="center_vertical"
            android:orientation="horizontal"
            android:paddingLeft="20dp"
            android:paddingRight="20dp" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/passenger" />

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:paddingLeft="5dp" >

                <TextView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/chosen_vehicle"
                    android:textSize="@dimen/text_size17sp" />

                <TextView
                    android:id="@+id/chosen_vehicle"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Dus One"
                    android:textSize="@dimen/text_size14sp" />
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

</LinearLayout>
like image 720
Soni Kumar Avatar asked Mar 10 '16 06:03

Soni Kumar


Video Answer


1 Answers

I have tried this check below code using RelativeLayout :

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

    <fragment
        android:id="@+id/mapForPlannedRide"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="180dp" />

    <LinearLayout
        android:id="@+id/departure_layout"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_below="@+id/mapForPlannedRide"
        android:gravity="center_vertical"
        android:orientation="horizontal"
        android:paddingLeft="20dp"
        android:paddingRight="20dp">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/passenger" />

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

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/departure"
                android:textSize="@dimen/text_size17sp" />

            <TextView
                android:id="@+id/departure"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="dfg ddfghd dfdg"
                android:textSize="@dimen/text_size14sp" />
        </LinearLayout>
    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight=".03"
        android:background="@color/line_color" />

    <LinearLayout
        android:id="@+id/destination_layout"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_below="@+id/departure_layout"
        android:gravity="center_vertical"
        android:orientation="horizontal"
        android:paddingLeft="20dp"
        android:paddingRight="20dp">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/passenger" />

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

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/destination"
                android:textSize="@dimen/text_size17sp" />

            <TextView
                android:id="@+id/destination"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Dilshad Garden Delhi"
                android:textSize="@dimen/text_size14sp" />
        </LinearLayout>
    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight=".03"
        android:background="@color/line_color" />

    <LinearLayout
        android:id="@+id/date_time_layout"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_below="@+id/destination_layout"
        android:gravity="center_vertical"
        android:orientation="horizontal"
        android:paddingLeft="20dp"
        android:paddingRight="20dp">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/passenger" />

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

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/date_time"
                android:textSize="@dimen/text_size17sp" />

            <TextView
                android:id="@+id/date_time"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="10:00 a.m."
                android:textSize="@dimen/text_size14sp" />
        </LinearLayout>
    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight=".03"
        android:background="@color/line_color" />

    <LinearLayout
        android:id="@+id/chosen_vehicle_layout"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_below="@+id/date_time_layout"
        android:gravity="center_vertical"
        android:orientation="horizontal"
        android:paddingLeft="20dp"
        android:paddingRight="20dp">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/passenger" />

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

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/chosen_vehicle"
                android:textSize="@dimen/text_size17sp" />

            <TextView
                android:id="@+id/chosen_vehicle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Dus One"
                android:textSize="@dimen/text_size14sp" />
        </LinearLayout>
    </LinearLayout>

    <ImageView
        android:layout_width="100dp"
        android:layout_height="50"
        android:layout_alignParentBottom="false"
        android:layout_alignParentRight="true"
        android:layout_centerHorizontal="true"
        android:layout_marginRight="20dp"
        android:layout_marginTop="150dp"
        android:src="@android:drawable/ic_reminder" />

</RelativeLayout>
like image 130
Amit Vaghela Avatar answered Sep 28 '22 15:09

Amit Vaghela