Add some more API demos for themes.

Shows how to make a basic custom theme with a custom background,
and a theme that selects between the old theme and Holo.

Also use a little trick to make the API demos for HC specific
samples be hidden on older versions of the platform.

Change-Id: Ie53e8103147e81975fca73b96bda989a00504534
This commit is contained in:
Dianne Hackborn
2011-01-16 14:28:13 -08:00
parent 560094efef
commit e63a4b58a2
9 changed files with 248 additions and 50 deletions

View File

@@ -35,6 +35,8 @@
<!-- For android.media.audiofx.Visualizer -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-sdk android:minSdkVersion="4" />
<!-- We will request access to the camera, saying we require a camera
of some sort but not one with autofocus capability. -->
<!--
@@ -152,7 +154,8 @@
</activity>
<activity android:name=".app.ActivityRecreate"
android:label="@string/activity_recreate">
android:label="@string/activity_recreate"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -244,7 +247,8 @@
<!-- Fragment Samples -->
<activity android:name=".app.FragmentAlertDialog"
android:label="@string/fragment_alert_dialog">
android:label="@string/fragment_alert_dialog"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -253,7 +257,8 @@
<activity android:name=".app.FragmentHideShow"
android:label="@string/fragment_hide_show"
android:windowSoftInputMode="stateUnchanged">
android:windowSoftInputMode="stateUnchanged"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -261,7 +266,8 @@
</activity>
<activity android:name=".app.FragmentContextMenu"
android:label="@string/fragment_context_menu">
android:label="@string/fragment_context_menu"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -269,7 +275,8 @@
</activity>
<activity android:name=".app.FragmentDialog"
android:label="@string/fragment_dialog">
android:label="@string/fragment_dialog"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -277,7 +284,8 @@
</activity>
<activity android:name=".app.FragmentDialogOrActivity"
android:label="@string/fragment_dialog_or_activity">
android:label="@string/fragment_dialog_or_activity"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -285,17 +293,20 @@
</activity>
<activity android:name=".app.FragmentLayout"
android:label="@string/fragment_layout">
android:label="@string/fragment_layout"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
<activity android:name=".app.FragmentLayout$DetailsActivity" />
<activity android:name=".app.FragmentLayout$DetailsActivity"
android:enabled="@bool/atLeastHoneycomb" />
<activity android:name=".app.FragmentListCursorLoader"
android:label="@string/fragment_list_cursor_loader">
android:label="@string/fragment_list_cursor_loader"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -303,7 +314,8 @@
</activity>
<activity android:name=".app.FragmentListArray"
android:label="@string/fragment_list_array">
android:label="@string/fragment_list_array"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -311,7 +323,8 @@
</activity>
<activity android:name=".app.FragmentMenu"
android:label="@string/fragment_menu">
android:label="@string/fragment_menu"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -319,7 +332,8 @@
</activity>
<activity android:name=".app.FragmentRetainInstance"
android:label="@string/fragment_retain_instance">
android:label="@string/fragment_retain_instance"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -327,7 +341,8 @@
</activity>
<activity android:name=".app.FragmentReceiveResult"
android:label="@string/fragment_receive_result">
android:label="@string/fragment_receive_result"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -335,7 +350,8 @@
</activity>
<activity android:name=".app.FragmentStack"
android:label="@string/fragment_stack">
android:label="@string/fragment_stack"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -346,7 +362,8 @@
<!-- BEGIN_INCLUDE(loader_throttle) -->
<activity android:name=".app.LoaderThrottle"
android:label="@string/loader_throttle">
android:label="@string/loader_throttle"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -719,14 +736,17 @@
<!-- Action Bar Samples -->
<activity android:name=".app.ActionBarMechanics"
android:label="@string/action_bar_mechanics">
android:label="@string/action_bar_mechanics"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
<activity android:name=".app.ActionBarUsage" android:label="@string/action_bar_usage">
<activity android:name=".app.ActionBarUsage"
android:label="@string/action_bar_usage"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -734,8 +754,9 @@
</activity>
<activity android:name=".app.ActionBarDisplayOptions"
android:label="@string/action_bar_display_options"
android:logo="@drawable/apidemo_androidlogo">
android:label="@string/action_bar_display_options"
android:logo="@drawable/apidemo_androidlogo"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -743,7 +764,8 @@
</activity>
<activity android:name=".app.ActionBarTabs"
android:label="@string/action_bar_tabs">
android:label="@string/action_bar_tabs"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -755,7 +777,8 @@
<!-- ************************************* -->
<activity android:name=".preference.FragmentPreferences"
android:label="@string/fragment_preferences">
android:label="@string/fragment_preferences"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -763,7 +786,8 @@
</activity>
<activity android:name=".preference.PreferenceWithHeaders"
android:label="@string/preference_with_headers">
android:label="@string/preference_with_headers"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -821,7 +845,9 @@
<!-- CONTENT PACKAGE SAMPLES -->
<!-- ************************************* -->
<activity android:name=".content.ClipboardSample" android:label="@string/activity_clipboard">
<activity android:name=".content.ClipboardSample"
android:label="@string/activity_clipboard"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -912,8 +938,10 @@
<!-- ANDROID.ANIMATION PACKAGE SAMPLES -->
<!-- ************************************* -->
<activity android:name=".animation.AnimationLoading" android:label="Animation/Loading"
android:hardwareAccelerated="false">
<activity android:name=".animation.AnimationLoading"
android:label="Animation/Loading"
android:hardwareAccelerated="false"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -921,24 +949,29 @@
</activity>
<activity android:name=".animation.AnimationCloning"
android:label="Animation/Cloning"
android:hardwareAccelerated="false">
android:label="Animation/Cloning"
android:hardwareAccelerated="false"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
<activity android:name=".animation.AnimationSeeking" android:label="Animation/Seeking"
android:hardwareAccelerated="false">
<activity android:name=".animation.AnimationSeeking"
android:label="Animation/Seeking"
android:hardwareAccelerated="false"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
<activity android:name=".animation.AnimatorEvents" android:label="Animation/Events"
android:hardwareAccelerated="false">
<activity android:name=".animation.AnimatorEvents"
android:label="Animation/Events"
android:hardwareAccelerated="false"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -946,8 +979,9 @@
</activity>
<activity android:name=".animation.BouncingBalls"
android:label="Animation/Bouncing Balls"
android:hardwareAccelerated="false">
android:label="Animation/Bouncing Balls"
android:hardwareAccelerated="false"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -955,23 +989,28 @@
</activity>
<activity android:name=".animation.CustomEvaluator"
android:label="Animation/Custom Evaluator"
android:hardwareAccelerated="false">
android:label="Animation/Custom Evaluator"
android:hardwareAccelerated="false"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
<activity android:name=".animation.ListFlipper" android:label="Animation/View Flip">
<activity android:name=".animation.ListFlipper"
android:label="Animation/View Flip"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
<activity android:name=".animation.ReversingAnimation" android:label="Animation/Reversing"
android:hardwareAccelerated="false">
<activity android:name=".animation.ReversingAnimation"
android:label="Animation/Reversing"
android:hardwareAccelerated="false"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -979,8 +1018,9 @@
</activity>
<activity android:name=".animation.MultiPropertyAnimation"
android:label="Animation/Multiple Properties"
android:hardwareAccelerated="false">
android:label="Animation/Multiple Properties"
android:hardwareAccelerated="false"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -988,7 +1028,8 @@
</activity>
<activity android:name=".animation.LayoutAnimations"
android:label="Animation/Layout Animations">
android:label="Animation/Layout Animations"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -996,7 +1037,8 @@
</activity>
<activity android:name=".animation.LayoutAnimationsHideShow"
android:label="Animation/Hide-Show Animations">
android:label="Animation/Hide-Show Animations"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -1004,7 +1046,8 @@
</activity>
<activity android:name=".animation.LayoutAnimationsByDefault"
android:label="Animation/Default Layout Animations">
android:label="Animation/Default Layout Animations"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -1684,7 +1727,8 @@
<activity android:name=".view.Controls3"
android:label="Views/Controls/3. Holo Light Theme"
android:theme="@android:style/Theme.Holo.Light">
android:theme="@android:style/Theme.Holo.Light"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -1693,7 +1737,26 @@
<activity android:name=".view.Controls4"
android:label="Views/Controls/4. Holo Dark Theme"
android:theme="@android:style/Theme.Holo">
android:theme="@android:style/Theme.Holo"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
<activity android:name=".view.Controls5"
android:label="Views/Controls/5. Custom Theme"
android:theme="@style/CustomTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
<activity android:name=".view.Controls6"
android:label="Views/Controls/6. Holo or Old Theme"
android:theme="@style/ThemeHolo">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -1889,7 +1952,8 @@
<activity android:name=".view.DragAndDropDemo"
android:label="Views/Drag and Drop"
android:hardwareAccelerated="false">
android:hardwareAccelerated="false"
android:enabled="@bool/atLeastHoneycomb">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />

View File

@@ -139,6 +139,14 @@
android:text="@string/listSeparatorTextViewStyle"
android:layout_marginTop="5dip"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="400dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="(And all inside of a ScrollView!)"
/>
</LinearLayout>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<!-- True if running under Honeycomb or later. -->
<bool name="atLeastHoneycomb">true</bool>
</resources>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<!-- For API level 11 or later, the Holo theme is available and we prefer that. -->
<style name="ThemeHolo" parent="android:Theme.Holo">
</style>
</resources>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<!-- This resource is true if running under at least Honeycomb's
API level. The default value is false; an alternative value
for Honeycomb is true. -->
<bool name="atLeastHoneycomb">false</bool>
</resources>

View File

@@ -15,6 +15,21 @@
-->
<resources>
<!-- A custom theme that is a variation on the light them with a different
background color. -->
<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>
<!-- This is a theme that will adjust itself depending on the API version.
The default definition is the safe one, using a theme that has always
been defined. Look at values-11/styles.xml for a variation that is
selected when the holographic theme is available. -->
<style name="ThemeHolo" parent="android:Theme">
</style>
<!-- Base application theme is the default theme. -->
<style name="Theme" parent="android:Theme">
</style>

View File

@@ -0,0 +1,19 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.apis.view;
public class Controls5 extends Controls1 {}

View File

@@ -0,0 +1,19 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.apis.view;
public class Controls6 extends Controls1 {}

View File

@@ -259,21 +259,31 @@
<h3>Controls</h3>
<dl>
<dt><a href="Controls1.html">1. Theme Light</a></dt>
<dt><a href="Controls1.html">1. Light Theme</a></dt>
<dd>Demonstrates a variety of common form type widgets, such as check boxes and radio buttons using the light theme. </dd>
</dl>
<dl>
<dt><a href="Controls1.html">2. Theme Dark</a></dt>
<dt><a href="Controls1.html">2. Dark Theme</a></dt>
<dd>Demonstrates a variety of common form type widgets, such as check boxes and radio buttons using the dark theme. </dd>
</dl>
<dl>
<dt><a href="Controls1.html">3. Theme Holographic Light</a></dt>
<dt><a href="Controls1.html">3. Holographic Light Theme</a></dt>
<dd>Demonstrates a variety of common form type widgets, such as check boxes and radio buttons using the light holographic theme. </dd>
</dl>
<dl>
<dt><a href="Controls1.html">4. Theme Holographic Dark</a></dt>
<dt><a href="Controls1.html">4. Holographic Dark Theme</a></dt>
<dd>Demonstrates a variety of common form type widgets, such as check boxes and radio buttons using the dark holographic theme. </dd>
</dl>
<dl>
<dt><a href="Controls1.html">5. Custom Theme</a></dt>
<dd>Demonstrates a variety of common form type widgets, such as check boxes and radio buttons using a custom
theme based on the light theme. </dd>
</dl>
<dl>
<dt><a href="Controls1.html">6. Holo or Old Theme</a></dt>
<dd>Demonstrates a variety of common form type widgets, such as check boxes and radio buttons using a custom
theme that uses either the traditional or holo theme depending on the version of the platform. </dd>
</dl>
<h3>Auto Complete</h3>
<dl>