Android Action Bar theme

南楼画角 提交于 2019-12-25 01:35:32

问题


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


回答1:


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!




回答2:


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

<!-- ... -->



回答3:


You are using : android:Theme.NoTitleBar.Fullscreen, try to use android:style/Theme.Holo instead and set your theme in manifest file as throrin19 suggest.



来源:https://stackoverflow.com/questions/14158772/android-action-bar-theme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!