简体   繁体   中英

Android Action Bar theme

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

How can i customize my ActionBar component using theme.xml. I tried to generate these files and did place in my platform/android/res folder , but no luck

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

You should add Theme in your manifest after placement in <yourproject>/res/* :

<!-- ... -->

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

<!-- ... -->

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

Do like that :

  <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>

In CustomActionBar style you can set ActionBar params. In your Activities use CustomStyle.

UPDATE : You can use CustomStyle in Manifest for all Application. Just do it :

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

Or use for each Activity :

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

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM