【问题标题】:How to set actionBar image with @style如何使用@style 设置actionBar 图像
【发布时间】:2017-10-17 09:57:24
【问题描述】:

我正在尝试使用@style 在我的活动中将drawable 设置为actionBar 的图像,但没有看到任何结果... 这是我的@styles:

<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:actionBarStyle">@style/MyActionBarTheme</item>
</style>

<style name="MyCustomTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyActionBarTheme</item>
</style>

<style name="MyActionBarTheme" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">@drawable/bgd</item>
</style>

这是我的活动代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:theme="@style/MyCustomTheme"
            android:layout_width="match_parent"
            android:layout_height="match_parent">


<com.roughike.bottombar.BottomBar
    android:id="@+id/bottomBar"
    android:layout_width="match_parent"
    android:layout_height="52dp"
    android:layout_alignParentBottom="true"
    app:bb_behavior="shifting|underNavbar"
    app:bb_tabXmlResource="@xml/bottombar_tabs_main_screen"/>

这就是我所拥有的:

就是那个actionBar,我想得到:

【问题讨论】:

  • 您是否在清单中包含了 MyCustomTheme 样式?
  • 你的应用主题是什么?您是否将 Theme.AppCompat 用于相关的 Activity 或 App 主题?你能提供你的清单代码吗?

标签: android background android-actionbar styles


【解决方案1】:

我正在尝试在确切的活动中使用它,这是我的清单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="org.workout.mauzerthecat.vesortupdate">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity"
              android:theme="@style/MyCustomTheme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application>

同样的结果;

【讨论】:

    【解决方案2】:

    解决方案是这样的(因为我正在使用 AppCompat):

    1. 我的风格:

      @style/动作栏 @style/动作栏

      @drawable/bgd @drawable/bgd @mipmap/ic_launcher_round @mipmap/ic_launcher_round 使用Logo|showHome

    2.我必须从我的 Manifest 文件中删除任何徽标属性; 3.你可以看这里Logo are not displayed in Actionbar, using AppCompat

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-06
      • 1970-01-01
      相关资源
      最近更新 更多