集switchStyle - 得到错误的资源没有发现 - 为什么?错误、发现、资源、switchStyle

2023-09-05 06:15:05 作者:疲惫无力的心

我遇到了一个奇怪的问题: 我是一个应用程序创建一个风格,我设置:

I ran into a strange Problem: I am creating a style for an app and I set:

<item name="android:spinnerStyle">@style/CustomSpinnerAppearance</item>  
<item name="android:textViewStyle">@style/CustomTextViewAppearance</item>
<item name="android:buttonStyle">@style/CustomButton</item>  

现在我想设置:

<item name="android:switchStyle">@style/CustomSwitch</item>

和我得到这个错误。

没有资源的发现,匹配给定的名字:ATTR   '机器人:switchStyle

No resource found that matches the given name: attr 'android:switchStyle'.

我在检查API-拉特14和15(ICS)源 attrs.xml 并有:

I have checked in API-Lvl 14 and 15 (ICS) source the attrs.xml and there is:

<attr name="switchStyle" format="reference" />

为什么我不能设置尽管开关部件自定义样式,该attr为在 attrs.xml

和更为重要的是:?我有什么做的,设置自定义样式的开关小部件应用广泛

And much more important: What do I have to do, to set a custom style for the Switch widget app wide?

推荐答案

按这个错误,它看起来是不可能的继承。

As per this bug, it looks like it isn't possible to inherit.

然而,作为一种解决方法,您可以覆盖现有的样式(如果它是你正在处理的只是颜色)通过在的 http://android-holo-colors.com/

However, as a workaround, you could override the existing style (if it's just colors that you're dealing with) by creating the appropriate 9-patches etc at http://android-holo-colors.com/

 
精彩推荐
图片推荐