13

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?

KarlKarlsom
  • 5,868
  • 4
  • 29
  • 36
  • Did you found a solution. I have the same problem. My themes.xml and styles.xml (values-v14) : – Jerome VDL Aug 23 '12 at 09:23
  • 2
    I have created an issue http://code.google.com/p/android/issues/detail?id=36636&thanks=36636&ts=1345753123 – Jerome VDL Aug 23 '12 at 21:01

2 Answers2

0

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/

saywhatnow
  • 1,026
  • 2
  • 15
  • 26
0

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

CChi
  • 3,054
  • 1
  • 20
  • 15
  • 1
    switchStyle is only defined in Theme.Holo after android OS 3.0. make sure you inheret from Theme.Holo and compile it with the right target version. – CChi Jan 25 '12 at 19:51
  • Target is 14 (4.0). After your comment I although tried 15. No change. – KarlKarlsom Jan 26 '12 at 04:10