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>
我有以下错误:
res/values-v14/styles.xml:4: error: Error retrieving parent for item:
No resource found that matches the given name
‘android:Widget.Holo.Light.CompoundButton.Switch’.res/values-v14/themes.xml:5: error: Error: No resource found that
matches the given name: attr ‘android:switchStyle’.
我对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>
我有以下错误:
/res/values-v11/themes.xml:26: error: Error: No resource found that
matches the given name: attr ‘android:numberPickerStyle’./res/values-v11/themes.xml:25: error: Error: No resource found that
matches the given name: attr ‘android:numberPickerDownButtonStyle’./res/values-v11/themes.xml:25: error: Error: No resource found that
matches the given name: attr ‘android:numberPickerUpButtonStyle’.
我的项目使用SDK 16,因此它应该可用…在eclipse和IntelliJ中出现相同的错误.
如何扩展这些风格?我可以用同样的方式扩展许多其他的(buttonStyle,buttonStyleToggle,seekBarStyle ……)
解决方法
您可以使用android-switch-backport或SwitchCompatLibrary.
他们也与Android Holo Colors合作
数字选择器还有另一种选择:Better Pickers
我希望我能提供帮助.