Orr
Orr

Reputation: 4840

Android place an image view between two views

I need to create a layout as shown in the image. The rounded button with the arrow needs to be exactly between the blue and the gray background. I'm having difficulties placing it without specifying the margins precisely, which is something I don't want to do because there is no guarantee it will look good on all resolutions and devices. I would appreciate an xml sample for that

Thanks! enter image description here

Upvotes: 2

Views: 3021

Answers (1)

Dhinakaran Thennarasu
Dhinakaran Thennarasu

Reputation: 3356

Screenshot

Use the desired drawable.. hope it works.. you can set width and height according to your need.

<?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" >

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

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

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dip"
                android:layout_weight="1"
                android:background="#1b96d9"
                android:orientation="vertical" >
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#e6e6e6"
                android:orientation="vertical" >
            </LinearLayout>
        </LinearLayout>

        <ImageView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:src="@drawable/arrow" />
    </FrameLayout>

</LinearLayout>

Upvotes: 2

Related Questions