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

前端之家收集整理的这篇文章主要介绍了无法覆盖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

我希望我能提供帮助.

原文链接:https://www.f2er.com/android/318382.html

猜你在找的Android相关文章