无法覆盖Android中的样式switchStyle和NumberPicker

我无法覆盖 android:switchStyle.这就是我所做的:

文件夹值-v14中,我有两个文件

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 ……)

解决方法

Switch小部件的样式不公开.

您可以使用android-switch-backportSwitchCompatLibrary.
他们也与Android Holo Colors合作

数字选择器还有另一种选择:Better Pickers

我希望我能提供帮助.

相关文章

这篇“android轻量级无侵入式管理数据库自动升级组件怎么实现...
今天小编给大家分享一下Android实现自定义圆形进度条的常用方...
这篇文章主要讲解了“Android如何解决字符对齐问题”,文中的...
这篇文章主要介绍“Android岛屿数量算法怎么使用”的相关知识...
本篇内容主要讲解“Android如何开发MQTT协议的模型及通信”,...
本文小编为大家详细介绍“Android数据压缩的方法是什么”,内...