Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the theme on an Android application?

Tags:

android

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

like image 513
Adham Avatar asked Nov 15 '10 22:11

Adham


People also ask

How do you change the color of your apps on Android?

To change the color of your apps on a Samsung phone, tap and hold an empty area of the home screen and then tap Wallpaper and style. Tap Color Palette, and then choose the color you want. Tap Set as Color Palette. The color palette changes will affect stock apps and icons.


2 Answers

Dev guide explains how to apply themes and styles.

This:

<TextView
    android: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>
    <style name="CodeFont" parent="@android:style/TextAppearance.Medium">
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:textColor">#00FF00</item>
        <item name="android:typeface">monospace</item>
    </style>
</resources>

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

<application android:theme="@style/CustomTheme">

Or just one activity:

<activity android:theme="@android:style/Theme.Dialog">
like image 167
Bryan Denny Avatar answered Sep 21 '22 21:09

Bryan Denny


public class MainActivity extends Activity {
      @Override
      public void onCreate(Bundle icicle) {
          setTheme(); // Put the resId as the parameter
          super.onCreate(icicle);
     }
}
like image 28
user1678551 Avatar answered Sep 23 '22 21:09

user1678551