设置 switchStyle - 找不到错误资源 - 为什么? [英] Set switchStyle - get error resource not found - why?

查看:42
本文介绍了设置 switchStyle - 找不到错误资源 - 为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个奇怪的问题:我正在为应用创建样式并设置:

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'android:switchStyle'.

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

我已经检查了 API-Lvl 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 中,但为什么我无法为开关小部件设置自定义样式?

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

更重要的是:我必须做什么才能为 Switch 小部件应用程序设置自定义样式?

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

推荐答案

根据 这个bug,好像不能继承.

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/

这篇关于设置 switchStyle - 找不到错误资源 - 为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆