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

前端之家收集整理的这篇文章主要介绍了无法覆盖Android中的样式switchStyle和NumberPicker前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我无法覆盖 android:switchStyle.这就是我所做的: @H_404_2@在文件夹值-v14中,我有两个文件

@H_404_2@themes.xml:

  1. <style name="AppTheme" parent="android:Theme.Holo.Light">
  2. <item name="android:switchStyle">@style/SwitchAppTheme</item>
  3. </style>
@H_404_2@styles.xml:

  1. <style name="SwitchAppTheme" parent="android:Widget.Holo.Light.CompoundButton.Switch">
  2. <item name="android:track">@drawable/switch_track_holo_light</item>
  3. <item name="android:thumb">@drawable/switch_inner_holo_light</item>
  4. </style>
@H_404_2@我有以下错误

@H_404_2@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’.

@H_404_2@res/values-v14/themes.xml:5: error: Error: No resource found that
matches the given name: attr ‘android:switchStyle’.

@H_404_2@我对NumberPicker有同样的问题:

@H_404_2@themes.xml:

  1. <item name="android:numberPickerUpButtonStyle">@style/NumberPickerButtonUpAppTheme</item>
  2. <item name="android:numberPickerDownButtonStyle">@style/NumberPickerButtonDownAppTheme</item>
  3. <item name="android:numberPickerStyle">@style/NumberPickerAppTheme</item>
@H_404_2@styles.xml:

  1. <style name="NumberPickerButtonUpAppTheme" parent="android:Widget.Holo.Light.ImageButton.NumberPickerUpButton">
  2. <item name="android:src">@drawable/numberpicker_up_btn_holo_light</item>
  3. </style>
  4.  
  5. <style name="NumberPickerButtonDownAppTheme" parent="android:Widget.Holo.Light.ImageButton.NumberPickerDownButton">
  6. <item name="android:src">@drawable/numberpicker_down_btn_holo_light</item>
  7. </style>
@H_404_2@我有以下错误

@H_404_2@/res/values-v11/themes.xml:26: error: Error: No resource found that
matches the given name: attr ‘android:numberPickerStyle’.

@H_404_2@/res/values-v11/themes.xml:25: error: Error: No resource found that
matches the given name: attr ‘android:numberPickerDownButtonStyle’.

@H_404_2@/res/values-v11/themes.xml:25: error: Error: No resource found that
matches the given name: attr ‘android:numberPickerUpButtonStyle’.

@H_404_2@我的项目使用SDK 16,因此它应该可用…在eclipse和IntelliJ中出现相同的错误.

@H_404_2@如何扩展这些风格?我可以用同样的方式扩展许多其他的(buttonStyle,buttonStyleToggle,seekBarStyle ……)

解决方法

Switch小部件的样式不公开. @H_404_2@您可以使用android-switch-backportSwitchCompatLibrary.
他们也与Android Holo Colors合作

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

@H_404_2@我希望我能提供帮助.

猜你在找的Android相关文章