2013-01-04 78 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的建議在清單文件中設置主題。