2013-01-07 34 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 

因此您可以更改整个应用程序主题。

相关问题