2013-01-04 80 views
0
<?xml version="1.0" encoding="utf-8"?> 
<resources> 
<style name="Theme.Titanium" parent="android:Theme.NoTitleBar.Fullscreen"> 
    <item name="android:windowBackground">@drawable/background</item> 
</style> 
</resources> 

如何使用theme.xml自定义我的ActionBar组件。我试图生成这些文件,并在我的platform/android/res folder那样的地方,但没有运气Android Action Bar主题

http://jgilfelt.github.com/android-actionbarstylegenerator/#name=ActionBar&compat=holo&theme=light&actionbarstyle=solid&backColor=ffffff%2C100&secondaryColor=1f6e0d%2C100&tertiaryColor=F2F2F2%2C100&accentColor=fafffb%2C100

+0

你正在使用哪个android平台,并使用Android Default ActionBar或ActionBarSherlock? – hardartcore

+0

我正在使用Android默认ActionBar。 – Kevin

+0

您是否在清单文件中添加样式,如下面的回答者所说的? – Kanth

回答

1

做这样的:

<style name="CustomStyle" parent="@android:style/Theme.Holo.Light"> 
     <item name="android:actionBarStyle">@style/CustomActionBar</item> 
    </style> 

    <style name="CustomActionBar" parent="@android:style/Widget.Holo.Light.ActionBar"> 
     <item name="android:background">@drawable/ANY_DRAWABLE</item> 
     <item name="android:displayOptions">useLogo|showHome</item> 
     ... 
     <item name="PARAM">VALUE</item> 
    </style> 

在CustomActionBar风格,你可以设置动作条PARAMS。在您的活动中使用CustomStyle。

UPDATE:您可以在Manifest中使用CustomStyle作为所有应用程序。只要做到这一点:

<application 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/CustomStyle"> 

或使用每个活动时间:

<activity 
    android:name="MainActivity" 
    android:label="@string/app_name" 
    android:screenOrientation="portrait" 
    android:theme="@style/CustomStyle"> 

祝你好运!

+0

如何在Manifest.xml中使用此CustomStyle – Kevin

+0

android:theme =“@ style/CustomStyle”你试过了吗? –

+0

我更新了我的帖子。 –

1

你应该在你的清单放置后<yourproject>/res/*添加主题:

<!-- ... --> 

<application 
    android:name="app.package" 
    android:icon="@drawable/icon" 
    android:label="@string/app_name" 
    android:theme="@style/Theme.Titanium"> 

<!-- ... --> 
1

您正在使用:android:Theme.NoTitleBar.Fullscreen,请尝试使用android:style/Theme.Holo,并按照throrin19的建议在清单文件中设置主题。