2010-11-15 24 views
7

मैं एक एंड्रॉइड एप्लिकेशन विकसित कर रहा हूं और मैं एप्लिकेशन के रंग और थीम को बदलना चाहता हूं। मैं यह कैसे कर सकता हूँ?मैं एंड्रॉइड एप्लिकेशन पर थीम कैसे बदलूं?

+5

+1 के रूप में यह एक अच्छा सवाल है, लेकिन एक गूगल खोज कम समय में आप एक जवाब दे दिया है की तुलना में ले लिया प्रश्न – Basic

+0

लिखने के लिए संबंधित: [रनटाइम पर थीम कैसे बदलें] (http://stackoverflow.com/questions/2482848/how-to-change-current-theme-at-runtime-in-android) – rds

उत्तर

9

Dev guide explains how to apply themes and styles.

यह:

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

इस बन जाता है:

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

तुम भी सभी एसी के लिए शैलियाँ लागू कर सकते हैं:

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

एक xml विषय फ़ाइल को परिभाषित करके एक आवेदन के tivities:

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

या सिर्फ एक गतिविधि:

<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); 
    } 
} 
संबंधित मुद्दे