Possible Duplicate:
Change icons of checked and unchecked for Checkbox for Android
customize check box preference
Is there any way to customize style of elements in PreferencesActivity?
I was only able to change color text, background etc.
I want to also change the check mark and radio button style in CheckBoxPreference and so on.
I'm interesting in API8 or greater.
Thanks for your help!
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<CheckBoxPreference
android:defaultValue="true"
android:key="vibrate"
android:summary="summary"
android:title="Some title"
android:widgetLayout="@layout/custom_checkbox" />
<CheckBoxPreference
android:defaultValue="true"
android:key="autorotate"
android:summary="summary"
android:title="auto rotate" />
</PreferenceScreen>
I understand what you are saying now. I thought you were just using normal
CheckBoxinside yourView. You are usingCheckBoxPreferenceand the otherPreferenceViews.Ok, well the concept is very similar.
You need to define a custom widget layout. Do this in your
res/layoutdirectory and call itcustom_checkbox.xml. We can use theCheckBoxas an example.Define how you would like the
CheckBoxPreferenceto look with the custom widget layout you create in theres/layoutdirectory by using aCheckBox. For instance:You can replace
android:buttonwith anydrawablethat you have found or designed.Now you need to define your
CheckBoxPreferenceand setting itsandroid:widgetLayoutto the customCheckBoxyou just defined inres/layout. For example:If you are not using
xmlfor defining yourlayoutyou can do it in code like this:Resources found that were similar to this question.
Konstantin Burov
Related links to extended questions from comments:
android-listview-style
spacing-between-listview-items-android