Thursday, June 2, 2011

[android-developers] Switching styles and themes

I've setup my widgets to all reference a style/theme that I've created
in "styles.xml", the individual buttons look something like this:

<!-- BUTTONS -->
<LinearLayout style="@style/CustomSetupWizard.ControlBackground"
android:id="@+id/LL2">

<Button style="@style/CustomButton.Cancel"
android:id="@android:id/button1"
android:text="@string/button_cancel"
android:layout_weight="1"/>

<Button style="@style/CustomButton.Continue"
android:id="@android:id/button2"
android:text="@string/button_continue"
android:layout_weight="1"/>
</LinearLayout>

Notice that they're all pointed at a named style, "Custom_xxx" which
is defined in styles.xml with an inheritance structure as described in
the developer reference. All is great with this.


What I'd like to do now, is switch the high level "CustomSetupWizard"
and "CustomButton" style or theme at runtime without needing to go and
redefine all the individual layout elements and widgets in each and
every layout. In essence, I'd like the "CustomSetupWizard" and
"CustomButton" styles to be a placeholder that I can override at
runtime with "setTheme()" when the application starts, without needing
to change the name reference in the layout objects.

Is this possible? How would I switch and/or redefine a high level
style set in styles.xml and force it to be named the same thing as far
as the widgets go.

I've tried using the folder approach, letting the platform select the
file based upon the -mdpi, -hdpi tags, but I need a finer level of
control over this when the application starts up.

Thanks,
DD

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate