If you do not explicitly specify a theme for your UI, Android will use the default theme defined by android.R.style.Theme. Many times you will want to use a different system theme (such as Theme.Light) or create your own theme (as described in Style and Theme Resources).
To set your theme in XML, simply specify the desired theme in your
AndroidManifest.xml file with the theme
attribute. This can be used with the
<application>
tag (shown here) to specify a default theme for all of your activities,
and/or with the
<activity>
to control
the theme of a particular activity.
<!-- AndroidManifest.xml--> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.home"> <application android:theme="@android:style/Theme.Dark" > <activity class=".Home" ... </activity> </application> </manifest>
You can also set the theme programmatically, if needed. When doing so, be sure to set the theme before creating any views so that the correct theme is used for all of your user-interface elements. Note that this approach should typically be avoided, especially from the main activities of your application, because the theme you set here may not be used for any animations the system uses to show the activity (which is done before your application starts).
protected void onCreate(Bundle icicle) { super.onCreate(icicle); ... setTheme(android.R.style.Theme_Light); setContentView(R.layout.linear_layout_3); }