Cannot override switchStyle and NumberPicker style in Android

I cannot override android: switchStyle. Here is what I did:

In the values โ€‹โ€‹of the v14 folder, I have two files:

themes.xml:

<style name="AppTheme" parent="android:Theme.Holo.Light"> <item name="android:switchStyle">@style/SwitchAppTheme</item> </style> 

styles.xml:

 <style name="SwitchAppTheme" parent="android:Widget.Holo.Light.CompoundButton.Switch"> <item name="android:track">@drawable/switch_track_holo_light</item> <item name="android:thumb">@drawable/switch_inner_holo_light</item> </style> 

I get the following errors:

res / values-v14 / styles.xml: 4: error: error getting parent element: A resource was not found matching the specified name. "Android: Widget.Holo.Light.CompoundButton.Switch

res / values-v14 / themes.xml: 5: error: error: resource not found matches the specified name: attr 'android: switchStyle'.

I have the same problem with NumberPicker:

themes.xml:

 <item name="android:numberPickerUpButtonStyle">@style/NumberPickerButtonUpAppTheme</item> <item name="android:numberPickerDownButtonStyle">@style/NumberPickerButtonDownAppTheme</item> <item name="android:numberPickerStyle">@style/NumberPickerAppTheme</item> 

styles.xml:

 <style name="NumberPickerButtonUpAppTheme" parent="android:Widget.Holo.Light.ImageButton.NumberPickerUpButton"> <item name="android:src">@drawable/numberpicker_up_btn_holo_light</item> </style> <style name="NumberPickerButtonDownAppTheme" parent="android:Widget.Holo.Light.ImageButton.NumberPickerDownButton"> <item name="android:src">@drawable/numberpicker_down_btn_holo_light</item> </style> 

I have the following errors:

/res/values-v11/themes.xml:26: error: Error: resource not found matches the specified name: attr 'android: numberPickerStyle'.

/res/values-v11/themes.xml:25: error: Error: resource not found matches the specified name: attr 'android: numberPickerDownButtonStyle'.

/res/values-v11/themes.xml:25: error: Error: resource not found matches the specified name: attr 'android: numberPickerUpButtonStyle'.

My project uses SDK 16, so it should be available ... The same error in eclipse and IntelliJ.

How to expand these styles? I can extend many others (buttonStyle, buttonStyleToggle, seekBarStyle ...) in the same way ...

+8
android styles android-widget
source share
1 answer

Styles for the Switch widget are not public.

You can use android-switch-backport or SwitchCompatLibrary . They also work with Android Holo Colors.

There is also an alternative for choosing a number: โ€œBetter Electorsโ€

I hope that I will help.

+4
source share

All Articles