1、在drawable目录下新建一个shape.xml(文件名随便取),文件内容如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFFFF" />
<stroke android:width="2dip" android:color="#00000000" />
<padding android:left="10dp" android:top="10dp" android:right="10dp"
android:bottom="10dp" />
<corners android:radius="10dp" />
</shape>
2、在布局文件下应用改文件如:
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="哈喽"
android:background="@drawable/shape">
</EditText>
1.设置提示信息
android:hint="input the PWD"
2、设置输入值的类型
android:inputType="number"
3、设置输入框包含的图片
android:drawableLeft="@drawable/baidu"
文件结构如图:
4、设置输入框的形状
android:background="@drawable/shape"
其中shape为上图中的xml文件
shape中内容为:
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充颜色 -->
<solid android:color="#ffffff"/>
<!-- 设置矩形的四个角为矩形 -->
<!-- 弧形的半径 -->
<corners android:radius="7dip"/>
</shape>