【问题标题】:Android Action Bar themeAndroid 操作栏主题
【发布时间】:2013-01-04 14:13:47
【问题描述】:
<?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,但没有运气

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

【问题讨论】:

  • 您在哪个 android 平台上工作,您使用的是 Android Default ActionBar 还是 ActionBarSherlock?
  • 我正在使用 Android Default ActionBar。
  • 您是否按照下面的回答者所说的那样在清单文件中添加了样式?

标签: android titanium-mobile


【解决方案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 样式中,您可以设置 ActionBar 参数。在您的活动中使用 CustomStyle。

更新:您可以在 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">

祝你好运!

【讨论】:

【解决方案2】:

&lt;yourproject&gt;/res/* 中放置后,您应该在清单中添加主题:

<!-- ... -->

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

<!-- ... -->

【讨论】:

    【解决方案3】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-15
      • 1970-01-01
      • 2015-04-22
      • 1970-01-01
      相关资源
      最近更新 更多