Fernando Tan
Fernando Tan

Reputation: 644

How to let ImageView partial overlap with 2 Buttons?

I would like to achieve below result i.e. one imageview in between and overlap with 2 buttons, but I have no luck after few days of trying and searching.

Many thank if you can help on this.

enter image description here

<LinearLayout
    android:id="@+id/fragment_busmain_triplacegroup"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/fragment_busmain_tripbtngroup"
    android:layout_centerHorizontal="true"
    android:orientation="vertical"
    android:padding="10dp"
    android:weightSum="2">

    <android.support.design.widget.TextInputLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">

        <EditText
            android:id="@+id/fragment_busmain_departfrom"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="@string/From"></EditText>
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">

        <EditText
            android:id="@+id/fragment_busmain_departto"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="@string/To"></EditText>
    </android.support.design.widget.TextInputLayout>
</LinearLayout>

Upvotes: 1

Views: 104

Answers (1)

vader
vader

Reputation: 909

Try using a RelativeLayout instead and add the ImageView below the first text view and give it a negative margin half its height.

<RelativeLayout
    android:id="@+id/fragment_busmain_triplacegroup"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/fragment_busmain_tripbtngroup"
    android:padding="10dp">

    <android.support.design.widget.TextInputLayout
        android:id="@id/from"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <EditText
            android:id="@+id/fragment_busmain_departfrom"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="@string/From"/>
    </android.support.design.widget.TextInputLayout>

    <ImageView
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_below="@id/from"
        android:src="@drawable/upDownArrow"
        android:layout_marginBottom="-15dp"/>

    <android.support.design.widget.TextInputLayout
        android:id="@id/to"
        android:layout_below="@id/from"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <EditText
            android:id="@+id/fragment_busmain_departto"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="@string/To"></EditText>
    </android.support.design.widget.TextInputLayout>
</RelativeLayout>

Upvotes: 1

Related Questions