//按照此代碼
把這些3個繪製文件RES /繪製的文件夾
simple_edittext.xml
<?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="#FFFFFF" />
<stroke
android:width="3dp"
android:color="#FB9820" />
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
</shape>
focus_edittext.xml
<?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="#58ACFA" />
<stroke
android:width="3dp"
android:color="#FB9820" />
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
</shape>
selector_edittext.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@drawable/focus_edittext"/>
<item android:drawable="@drawable/simple_edittext" />
</selector>
,並使用這些drawbles這樣的:
<EditText
android:id="@+id/layout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_marginBottom="10dp"
android:background="@drawable/selector_edittext"
android:text="@string/hello_world" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/layout1"
android:padding="10dp"
android:background="@drawable/selector_edittext"
android:text="@string/hello_world" />
你試過在繪製? –
不,我不知道如何使用它。我想要chenage textcolor和背景焦點@ChiragSavsani Savsani – donoachua