問(wèn)題描述
我有一個(gè)帶有 drawableLeft
圖像的 EditText
.我需要在我的 drawableLeft
旁邊的 EditText
中添加一條垂直線,如下例所示:
I have an EditText
with a drawableLeft
image. I need to add a vertical line in EditText
right beside my drawableLeft
like this example:
我能想到的最簡(jiǎn)單的方法是將這條線添加到我的可繪制圖像中.但是一般有沒(méi)有其他方法可以做到這一點(diǎn)?
Easiest way that I can think of is to add that line into my drawable image. But generally is there any other way to do this?
推薦答案
在 res/drawable/shape.xml 中創(chuàng)建一個(gè)矩形圓角形狀
Create a rectangular rounded corner shape in res/drawable/shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="3dip" android:color="@android:color/darker_gray" />
<corners android:radius="10dip"/>
<padding android:left="10dip" android:top="10dip" android:right="10dip" android:bottom="10dip" />
</shape>
現(xiàn)在創(chuàng)建一個(gè)布局
Now create a layout
<?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="wrap_content"
android:background="@drawable/shape"
android:gravity="center_vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@drawable/ic_launcher"/>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@android:color/darker_gray"
android:layout_marginLeft="10dp"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_weight="1"
android:background="@null"
android:layout_marginLeft="10dp"
android:hint="Your bitcoin address here"/>
</LinearLayout>
我已將線性布局背景設(shè)置為矩形圓角形狀.和urs的圖片預(yù)覽一模一樣.
I have set the Linear layout background with th rectangular rounded corner shape. It looks exactly as the image preview of urs.
這篇關(guān)于Android EditText 在其可繪制對(duì)象和文本之間繪制分隔線的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!