diff options
author | Dianne Hackborn <hackbod@google.com> | 2011-02-07 19:11:54 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-02-07 19:11:54 -0800 |
commit | 1fb7a75ca54a061c5dd78857ad395695b3e85972 (patch) | |
tree | 98080196345fb44bc19a15a8e2210021c2f8de8e | |
parent | c1a35d2b1a2c3e784b9f49e009f254452fd2acca (diff) | |
parent | 5592b0d8fe30c84a4bd8909b5be4166e890d9853 (diff) | |
download | frameworks_base-1fb7a75ca54a061c5dd78857ad395695b3e85972.zip frameworks_base-1fb7a75ca54a061c5dd78857ad395695b3e85972.tar.gz frameworks_base-1fb7a75ca54a061c5dd78857ad395695b3e85972.tar.bz2 |
am 5592b0d8: am ae91b5ac: Update theme documentation a bit.
* commit '5592b0d8fe30c84a4bd8909b5be4166e890d9853':
Update theme documentation a bit.
-rw-r--r-- | docs/html/guide/topics/ui/themes.jd | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/docs/html/guide/topics/ui/themes.jd b/docs/html/guide/topics/ui/themes.jd index de699f2..57c9f2e 100644 --- a/docs/html/guide/topics/ui/themes.jd +++ b/docs/html/guide/topics/ui/themes.jd @@ -17,6 +17,7 @@ parent.link=index.html <ol> <li><a href="#ApplyAStyle">Apply a style to a View</a></li> <li><a href="#ApplyATheme">Apply a theme to an Activity or application</a></li> + <li><a href="#SelectATheme">Select a theme based on platform version</a></li> </ol> </li> <li><a href="#PlatformStyles">Using Platform Styles and Themes</a></li> @@ -303,21 +304,57 @@ appear like a dialog box:</p> </pre> <p>If you like a theme, but want to tweak it, just add the theme as the <code>parent</code> -of your custom theme. For example, you can modify the traditional dialog theme to use your own -background image like this:</p> +of your custom theme. For example, you can modify the traditional light theme to use your own +color like this:</p> <pre> -<style name="CustomDialogTheme" parent="@android:style/Theme.Dialog"> - <item name="android:windowBackground">@drawable/custom_dialog_background</item> +<color name="custom_theme_color">#b0b0ff</color> +<style name="CustomTheme" parent="android:Theme.Light"> + <item name="android:windowBackground">@color/custom_theme_color</item> + <item name="android:colorBackground">@color/custom_theme_color</item> </style> </pre> -<p>Now use {@code CustomDialogTheme} instead of {@code Theme.Dialog} inside the Android +<p>(Note that the color needs to supplied as a separate resource here because +the <code>android:windowBackground</code> attribute only supports a reference to +another resource; unlike <code>android:colorBackground</code>, it can not be given +a color literal.)</p> + +<p>Now use {@code CustomTheme} instead of {@code Theme.Light} inside the Android Manifest:</p> <pre> -<activity android:theme="@style/CustomDialogTheme"> +<activity android:theme="@style/CustomTheme"> +</pre> + +<h3 id="SelectATheme">Select a theme based on platform version</h3> + +<p>Newer versions of Android have additional themes available to applications, +and you may want to use these while running on those platforms while still being +compatible with older versions. You can accomplish this through a custom theme +that uses resource selection to switch between different parent themes.</p> + +<p>For example, here is the declaration for a custom theme which is simply +the standard platforms default light theme. It would go in an XML file under +<code>res/values</code> (typically <code>res/values/styles.xml</code>): +<pre> +<style name="LightThemeSelector" parent="android:Theme.Light"> +</style> +</pre> + +<p>To have this theme use the newer "holo" theme when the application is running +on {@link android.os.Build.VERSION_CODES#HONEYCOMB}, you can place another +declaration for it in a file in <code>res/values-11</code>:</p> +<pre> +<style name="LightThemeSelector" parent="android:Theme.Holo.Light"> +</style> </pre> +<p>Now use this theme like you would any other, and your application will +automatically switch to the holo theme if running on +{@link android.os.Build.VERSION_CODES#HONEYCOMB} or later.</p> + +<p>A list of the standard attributes that you can use in themes can be +found at {@link android.R.styleable#Theme R.styleable.Theme}.</p> <!-- This currently has some bugs |