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