如何使用@style 设置actionBar 图像
How to set actionBar image with @style
我正在尝试使用@style 在我的 activity 中将可绘制对象设置为 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>
这是我的 activity 代码:
<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,我要获取:
我正在尝试准确地使用它 activity,这是我的清单:
<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>
同样的结果;
解决方案是这样的(因为我正在使用 AppCompat):
我的风格:
@style/ActionBar
@style/ActionBar
@drawable/bgd
@drawable/bgd
@mipmap/ic_launcher_round
@mipmap/ic_launcher_round
使用Logo|showHome
2.I 不得不从我的清单文件中删除任何徽标属性;
3.你可以在这里看到Logo are not displayed in Actionbar, using AppCompat
我正在尝试使用@style 在我的 activity 中将可绘制对象设置为 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>
这是我的 activity 代码:
<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,我要获取:
我正在尝试准确地使用它 activity,这是我的清单:
<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>
同样的结果;
解决方案是这样的(因为我正在使用 AppCompat):
我的风格:
@style/ActionBar @style/ActionBar
@drawable/bgd @drawable/bgd @mipmap/ic_launcher_round @mipmap/ic_launcher_round 使用Logo|showHome
2.I 不得不从我的清单文件中删除任何徽标属性; 3.你可以在这里看到Logo are not displayed in Actionbar, using AppCompat