Set switchStyle - get error resource not found - why?

☆樱花仙子☆ 提交于 2020-01-01 02:10:06

问题


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>  

Now I wanted to set:

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

And I get this error.

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

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

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

Why I cant set a custom style for the switch widget despite the fact, that the attr is in attrs.xml?

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


回答1:


try dropping "android:" in @style/CustomSwitch0. I believe you can only use the android namespace only if you are able to find it in here http://developer.android.com/reference/android/R.styleable.html




回答2:


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

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/



来源:https://stackoverflow.com/questions/9006894/set-switchstyle-get-error-resource-not-found-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!