2012-07-23 102 views
0

我有一個快速問題。默認應用程序主題

有沒有一種方法,使用eclipse爲我的應用程序定義默認主題,還是我必須配置每個活動和資產以匹配我想要的主題?

如果有辦法,我該怎麼做呢?

回答

1

在res \ values中創建一個xml文件。在它創建這樣一個默認的佈局風格(你可以定義其他的東西也這只是一個例子):

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

這TextView的,現在將繼承在樣式聲明的設置。

+0

更好的幫助!謝謝! – Madonk 2012-07-23 20:49:00

3

定義您的android:themeapplication清單中的元素。

+0

好的,謝謝!我會仔細看看的! – Madonk 2012-07-23 20:21:19