不知不觉,已经上班了好几天了,为了让我可以更好的记忆我学的知识,也为了方便我自己查找资料,所以决定将它写出来,和大家分享。


       安卓自带的EditText控件,在不同的手机中显示的格式有很大的差别,有的只是一条横线,有的是矩形框,为了统一格式,我们通常需要对其进行一些简单的操作,下面我介绍一种将其设置为圆角框的方式。

    首先需要在drawable中新建一个round_editstyle的xml文件:

zx

?xml version="1.0" encoding="utf-8"?>
<!-- 设置圆角边框 -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:padding="10dp"
    android:shape="rectangle" >

    <solid android:color="#ff0122" />

    <corners
        android:bottomLeftRadius="30dp"
        android:bottomRightRadius="30dp"
        android:topLeftRadius="30dp"
        android:topRightRadius="30dp" />

</shape>

圆角的弧度可以自己调,我设置它为30度。之后我们就可以在布局文件中直接在background标签中引用它了:

<EditText
        
        android:layout_marginTop="100dp"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:hint="EditTextDemo"
        android:gravity="center"
        android:background="@drawable/rounder_editstyle" />

andriod中设置EditText的圆角弧度_圆角