Skip to content Skip to sidebar Skip to footer

How Do I Change The Theme On An Android Application?

I'm developing an Android application and I want to change the color and theme of the application. How can I do this?

Solution 1:

Dev guide explains how to apply themes and styles.

This:

<TextViewandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:textColor="#00FF00"android:typeface="monospace"android:text="@string/hello" />

Becomes this:

<TextView
    style="@style/CodeFont"
    android:text="@string/hello" />

By defining an xml theme file:

<?xml version="1.0" encoding="utf-8"?><resources><stylename="CodeFont"parent="@android:style/TextAppearance.Medium"><itemname="android:layout_width">fill_parent</item><itemname="android:layout_height">wrap_content</item><itemname="android:textColor">#00FF00</item><itemname="android:typeface">monospace</item></style></resources>

You can also apply styles to all activities of an application:

<applicationandroid:theme="@style/CustomTheme">

Or just one activity:

<activityandroid:theme="@android:style/Theme.Dialog">

Solution 2:

publicclassMainActivityextendsActivity {
      @OverridepublicvoidonCreate(Bundle icicle) {
          setTheme(); // Put the resId as the parametersuper.onCreate(icicle);
     }
}

Post a Comment for "How Do I Change The Theme On An Android Application?"