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
CheckBox
inside yourView
. You are usingCheckBoxPreference
and the otherPreference
Views
.Ok, well the concept is very similar.
You need to define a custom widget layout. Do this in your
res/layout
directory and call itcustom_checkbox.xml
. We can use theCheckBox
as an example.Define how you would like the
CheckBoxPreference
to look with the custom widget layout you create in theres/layout
directory by using aCheckBox
. For instance:You can replace
android:button
with anydrawable
that you have found or designed.Now you need to define your
CheckBoxPreference
and setting itsandroid:widgetLayout
to the customCheckBox
you just defined inres/layout
. For example:If you are not using
xml
for defining yourlayout
you 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