custom-widgets

Custom SwitchPreference in Android

亡梦爱人 提交于 2019-11-27 14:46:03
How to set a custom style or other background selector drawable for the SwitchPreference widget in Android? (Note: not the regular Switch widget, I mean the standart SwitchPreference widget that used in PreferenceActivity / PreferenceFragment ) Mike 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

Custom SwitchPreference in Android

天涯浪子 提交于 2019-11-26 16:54:25
问题 How to set a custom style or other background selector drawable for the SwitchPreference widget in Android? (Note: not the regular Switch widget, I mean the standart SwitchPreference widget that used in PreferenceActivity / PreferenceFragment ) 回答1: 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