[android-developers] Re: Themes and styles
OK, found a working solution - no idea if it was indented that way, SDK documentation is very fuzzy and incomplete in this area... To stay with my example: In attrs.xml, define the CSS class ;): resources attr name=headline format=reference / /resources In styles.xml, define the style to use for each theme: style name=Theme.Android.Black parent=android:Theme.Black item name=android:textViewStyle@style/textForBlack/item item name=headline@style/headlineForBlack/item /style style name=Theme.Android.Light parent=android:Theme.Light item name=android:textViewStyle@style/textForLight/item item name=headline@style/headlineForWhite/item /style In the layout, refer to the attribute with ?: TextView . style=?headline / Hope this helps other people with similar problems... On a related topic: Does anybody have an idea how to support themes from external (ZIP?) files including the required drawables? Or, in other words, user skins. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Themes and styles
Both in the O'Reilly online tutorials and in the Meetups, I have heard it said often: to make sense of what really goes on in the XML for styles and themes, you often have to break down and read the source code; especially if you are doing anything custom. I can't approve of that state of affairs, it really does sound like a failure of the documentation, but like the old joke goes: when you run up against a sheer cliff, even the fastest runner finds his feet useless. There's not much we can do other than bit the bullet and read the code. On Sep 7, 3:07 am, mort m...@sto-helit.de wrote: OK, found a working solution - no idea if it was indented that way, SDK documentation is very fuzzy and incomplete in this area... To stay with my example: In attrs.xml, define the CSS class ;): resources attr name=headline format=reference / /resources In styles.xml, define the style to use for each theme: style name=Theme.Android.Black parent=android:Theme.Black item name=android:textViewStyle@style/textForBlack/item item name=headline@style/headlineForBlack/item /style style name=Theme.Android.Light parent=android:Theme.Light item name=android:textViewStyle@style/textForLight/item item name=headline@style/headlineForWhite/item /style In the layout, refer to the attribute with ?: TextView . style=?headline / Hope this helps other people with similar problems... On a related topic: Does anybody have an idea how to support themes from external (ZIP?) files including the required drawables? Or, in other words, user skins. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Themes and styles
I fear that allowing the user to dynamically select a new skin (even with a restart of your app) is a very very difficult thing to do, if not impossible. There is a method called 'Activity.setTheme(int resourceId)', but this changes only the theme and would allow for dynamically changing only a small sub-set of all possible properties/attributes on views. There are no methods like 'View.setStyle(int resourceId)' or similar ones nor is it possible to program a dynamic selection of a particular custom made configuration. (Try to search for 'setTheme' in this group and you'll see that there are(/were?) some issues this method.) If i'm wrong, i'd love to know how one can implement user-selectable skins. On Sep 7, 6:07 am, mort m...@sto-helit.de wrote: OK, found a working solution - no idea if it was indented that way, SDK documentation is very fuzzy and incomplete in this area... To stay with my example: In attrs.xml, define the CSS class ;): resources attr name=headline format=reference / /resources In styles.xml, define the style to use for each theme: style name=Theme.Android.Black parent=android:Theme.Black item name=android:textViewStyle@style/textForBlack/item item name=headline@style/headlineForBlack/item /style style name=Theme.Android.Light parent=android:Theme.Light item name=android:textViewStyle@style/textForLight/item item name=headline@style/headlineForWhite/item /style In the layout, refer to the attribute with ?: TextView . style=?headline / Hope this helps other people with similar problems... On a related topic: Does anybody have an idea how to support themes from external (ZIP?) files including the required drawables? Or, in other words, user skins. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Themes and styles
On Tue, Sep 7, 2010 at 3:07 AM, mort m...@sto-helit.de wrote: On a related topic: Does anybody have an idea how to support themes from external (ZIP?) files including the required drawables? Or, in other words, user skins. You can't do this. Also themes are not really intended to be used to implement skins. The name was deliberately chosen to not be a skin, that is for something else whenever it gets implemented. :) The purpose of themes is to provide *static* standard presentations. That is, the kind of stuff you see in the standard themes -- one for a UI with a dark background, one for a light background, one for a dialog, etc. Trying to use them to change your app's appearance dynamically... well, it's not really intended to be used that way, so it is going to be some effort As far as documentation -- yes full extensive documentation would be nice, but the such documentation on this stuff has been a much lower priority than many other things. As always, contributions welcome. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en