简体   繁体   English

Android Action Bar主题

[英]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. 如何使用theme.xml自定义我的ActionBar组件。 I tried to generate these files and did place in my platform/android/res folder , but no luck 我试图生成这些文件,并确实放置在我的platform/android/res folder ,但是没有运气

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 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/* : 放置在<yourproject>/res/*之后,应该在清单中添加Theme:

<!-- ... -->

<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. 在CustomActionBar样式中,可以设置ActionBar参数。 In your Activities use CustomStyle. 在您的活动中使用CustomStyle。

UPDATE : You can use CustomStyle in Manifest for all Application. 更新:您可以在清单中为所有应用程序使用CustomStyle。 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! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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