checkbox
1.首先在drawable文件夹中添加drawable文件checkbox_style.xml。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/duigou" android:state_checked="true"/>
<item android:drawable="@drawable/duigou0" android:state_checked="false"/>
<item android:drawable="@drawable/duigou0" />
</selector>
2.在values文件夹下的styles.xml文件中添加CustomCheckboxTheme样式。
<style name="CustomCheckboxTheme" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/checkbox_style</item>
</style>
3.在布局文件中使用CustomCheckboxTheme样式。
<CheckBox
android:id="@+id/remember"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/CustomCheckboxTheme"
android:text="@string/remember"/>
//************************************************************************************
edittext
1.首先在drawable文件夹中添加drawable文件editview_style.xml。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/focused" android:state_focused="true" />
<item android:drawable="@drawable/disabled" android:state_focused="false"/>
<item android:drawable="@drawable/disabled" />
</selector>
2.在values文件夹下的styles.xml文件中添加CustomEditviewTheme样式。
<style name="CustomEditviewTheme" parent="@android:style/Widget.EditText">
<item name="android:background">@drawable/editview_style</item>
</style>
3.在布局文件中使用CustomCheckboxTheme样式。
<EditText
style="@style/CustomEditviewTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Contact phone"
android:inputType="phone"
android:id="@+id/EContactphone"
/>