可以使用图像创建的Edittext吗? Android的

时间:2015-01-06 10:23:30

标签: android layout

enter image description here

您好我想创建以下edittext,但我不知道如何,我认为只需添加它作为背景将有助于som填充,但它不

1 个答案:

答案 0 :(得分:-1)

您可以在drawable中创建xml文件,然后将该xml作为背景应用于您的edittext。 以下代码示例将为您的edittext添加圆角

rounded_corners.xml

<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<!-- view background color -->
<solid
    android:color="@android:color/transparent" >
</solid>

<!-- view border color and width -->
<stroke
    android:width="2dp"
    android:color="#ff6600" >
</stroke>

<!-- If you want to add some padding -->
<padding
    android:left="4dp"
    android:top="4dp"
    android:right="4dp"
    android:bottom="4dp"    >
</padding>

<!-- Here is the corner radius -->
<corners
    android:radius="10dp"   >
</corners>

</shape>

然后在您的布局文件中将此xml应用于editext

           <EditText
                android:id="@+id/neworder_route_from"
                android:background="@drawable/rounded_corners"
                android:layout_margin="8dp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="From"
                android:padding="10dp" />