2013-01-07 32 views
1

我使用Theme.Sherlock.Light.DarkActionBar爲我的整個應用程序。現在操作欄背景顏色默認爲黑色。如何改變這種顏色。基本上如何自定義整個應用程序的主題?如何自定義整個應用程序的主題

<activity 
      android:name="com.mypath.myapp.FirstActivity" 
      android:label="@string/app_name" 
      android:theme="@style/Theme.Sherlock.Light.DarkActionBar" 
      > 
+0

http://whathaveyoutried.com? – njzk2

回答

1

您可以在<application>標記中使用android:theme=theme_style。現在,如果您希望動作欄與主題給出的動作欄不同,則可以通過專門爲您的動作欄定義<style></style之間的樣式來覆蓋它。

這是概念。去res > values > styles.xml。您可以如下擴展或自定義主題:

 <style name="AppBaseTheme" parent="android:Theme.Light"> 
      <item name="android:background">@color/background_dark</item> 
     </style> 

更新: 或者如果你想爲所有應用程序的通用(不是主題特定)的變化,那麼你可以編輯sdk/platforms/android-target/data/res/values/styles.xml

或者如果你要覆蓋所有應用程序的默認主題,那麼您可以編輯sdk/platforms/android-target/data/res/values/themes.xml

更新 - 發現這個:

ActionBar developer docs。該鏈接指出:「您可以使用在Android 3.0(API級別11)中添加的ActionBar API來控制操作欄的行爲和可見性。」所以我認爲你的目標至少是API 11。

如果你的目標API 11以上,你可以做高級定製樣式如下:

<resources> 
      <style name="CustomActivityTheme" parent="@android:style/Theme.Holo"> 
       <item name="android:actionBarStyle">@style/MyActionBar</item> 
      </style> 

      <style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar"> 
       <item name="android:background">@drawable/ab_background</item> 
       <item name="android:backgroundStacked">@drawable/ab_background</item> 
       <item name="android:backgroundSplit">@drawable/ab_split_background</item> 
      </style> 
    </resources> 

在這裏你去,Styling Action Bar background

+0

這裏是什麼是android:theme = theme_style?它是android:theme =「@ style/AppBaseTheme」 – Ramprasad

+0

是的。這是主題的風格資源。 –

+0

改變了Actitviy的整個背景.. – Ramprasad

0

您可以在應用程序代碼的清單文件定義整個應用程序的主題如下:

<application 
    android:name="com.test" 
    android:icon="@drawable/appicon" 
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.NoTitleBar" > <---Define your own style here. 
0

修改默認的Android SDK中的主題,您可以找到Android SDK中的主題.xml文件位於:

\android-sdk\platforms\...\data\res\values\themes.Xml 

因此您可以更改整個應用程序主題。

相關問題