现在的位置: 首页 > 综合 > 正文

在android中创建圆角的文本框的实现

2013年12月09日 ⁄ 综合 ⁄ 共 929字 ⁄ 字号 评论关闭

在很多android的应用程序中,我们经常可以看到圆角的文本编辑框,那是怎么实现的呢?就像下图这种:

解决方案来自于CSDN问答,以下只是其中一种,更多方法见http://ask.csdn.net/questions/885

需要两个shape绘制文件

对于顶部的EditText,调用这个,top_edittext_bg

<?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

<?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

抱歉!评论已关闭.