Custom SwitchPreference in Android

You have to create a custom layout for the switch itself and you can apply it dynamically like. preference.setWidgetLayoutResource(R.layout.custom_switch); But I’ll go into details and show you exactly how to achieve this. So, you define your preference in an xml file like preferences.xml <?xml version=”1.0″ encoding=”utf-8″?> <PreferenceScreen xmlns:android=”http://schemas.android.com/apk/res/android” > <PreferenceCategory android:title=”YOUR_CATEGORY_TITLE” > <SwitchPreference android:key=”SWITCH” android:title=”YOUR_TITLE_FOR_SWITCH” … Read more