在android中创建圆角的文本框的实现
在很多android的应用程序中,我们经常可以看到圆角的文本编辑框,那是怎么实现的呢?
需要两个shape绘制文件
对于顶部的EditText,调用这个,top_edittext_bg:
[javascript]
01.<?xml version="1.0" encoding="utf-8"?>
02.<shape xmlns:android="http://schemas.android.com/apk/res/android"
03. android:shape="rectangle" >
04.
05. <solid
06. android:color="#e2e2e2" >
07. </solid>
08.
09. <corners
10. android:radius="1dp"
11. android:bottomLeftRadius="0.1dp"
12. android:bottomRightRadius="0.1dp"
13. android:topLeftRadius="5dp"
14. android:topRightRadius="5dp" >
15. </corners>
16.
17.</shape>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid
android:color="#e2e2e2" >
</solid>
<corners
android:radius="1dp"
android:bottomLeftRadius="0.1dp"
android:bottomRightRadius="0.1dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" >
</corners>
</shape>
对于中间的EditText,调用这个,bottom_edittext_bg:
[javascript]
01.<?xml version="1.0" encoding="utf-8"?>
02.<shape xmlns:android="http://schemas.android.com/apk/res/android"
03. android:shape="rectangle" >
04.
05. <solid
06. android:color="#e2e2e2" >
07. </solid>
08.
09. <corners
10. android:radius="1dp"
11. android:bottomLeftRadius="5dp"
12. android:bottomRightRadius="5dp"
13. android:topLeftRadius="0.1dp"
14. android:topRightRadius="0.1dp" >
15. </corners>
16.
17.</shape>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid
android:color="#e2e2e2" >
</solid>
<corners
android:radius="1dp"
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="0.1dp"
android:topRightRadius="0.1dp" >
</corners>
</shape>然后设置这个在android:background="@drawable/RESPECTIVE_XMLS"属性给相关联的EditText's
补充:移动开发 , Android ,