2010-11-15 7 views
7

Ich entwickle eine Android-Anwendung und möchte die Farbe und das Design der Anwendung ändern. Wie kann ich das machen?Wie ändere ich das Design in einer Android-Anwendung?

+5

+1, da es eine gute Frage, aber eine Google-Suche Sie in kürzerer Zeit eine Antwort haben gegeben würde, als es dauerte um die Frage zu schreiben – Basic

+0

Related: [Wie Theme zur Laufzeit wechseln] (http://stackoverflow.com/questions/2482848/how-to-change-current-theme-at-runtime-in-android) – rds

Antwort

9

Dev guide explains how to apply themes and styles.

Dieses:

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

Wird dies:

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

eine XML-Theme-Datei Durch die Definition:

<?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> 

Sie können auch Stile für alle ac gelten tivities einer Anwendung:

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

oder nur eine Aktivität:

<activity android:theme="@android:style/Theme.Dialog"> 
3
public class MainActivity extends Activity { 
     @Override 
     public void onCreate(Bundle icicle) { 
      setTheme(); // Put the resId as the parameter 
      super.onCreate(icicle); 
    } 
} 
Verwandte Themen