简体   繁体   中英

Put Image View above Button - Android

I have some XML that looks like this

<!--
<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/divider"
    android:layout_centerHorizontal="true"
    android:background="#ffffff"
    android:minWidth="2dp"
    android:layout_below="@+id/emailField" />
-->

<Button
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="1"
    android:id="@+id/Btn1"
    android:background="#907F0106"
    android:layout_below="@+id/emailField"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:textColor="#ffffff" />

<Button
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="2"
    android:id="@+id/Btn2"
    android:background="#907F0106"
    android:textColor="#ffffff"
    android:layout_below="@+id/emailField"
    android:layout_alignRight="@+id/emailField"
    android:layout_alignEnd="@+id/emailField" />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/divider"
    android:layout_centerHorizontal="true"
    android:background="#ffffff"
    android:minWidth="2dp"
    android:layout_below="@+id/emailField" />

I have tried it above and below but it always looks like it is partly hidden behind the buttons, as seen below

But I want a full white line going down, not one that is partly hidden behind? 在此处输入图片说明

Try using view instead of ImageView

<View
android:id="@+id/view"
android:layout_width="match_parent" 
android:layout_height="2dp"
android:layout_below="@+id/relativeLayout"
android:background="@color/yourDesiredColor" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM