编辑EditText边框的最专业方式

时间:2012-12-05 20:04:53

标签: android

简单地说,我想更改EditText的边框。

我不知道是否可以通过添加/res/drawable/editborders.xml

之类的东西来做到这一点

<item>
    <shape android:shape="rectangle" >
        <corners
            android:bottomLeftRadius="2dp"
            android:bottomRightRadius="2dp"
            android:topLeftRadius="2dp"
            android:topRightRadius="2dp" />

        <stroke
            android:width="2dp"
            android:color="#8b3732" />

        <solid android:color="#ff000000" />
    </shape>
</item>

请注意,上述代码只不过是我试用的一个例子。

我希望边框更像是渐变而不是简单的颜色。例如:

enter image description here

如果我们仔细观察,我们会注意到一个渐变:

enter image description here

这就是我想要的方式,专业的方式,任何专家都可以解决我的问题?

2 个答案:

答案 0 :(得分:1)

您可以使用9补丁图片作为EditText的背景。

答案 1 :(得分:0)

你可以使用渐变来实现类似的东西:

<gradient
android:angle="270"
android:startColor="#67e203"
android:centerColor="#51b500"
android:endColor="#59c601"
android:type="linear"
/>  

希望它有所帮助。