发生了什么:
Theme.AppCompat.Light.DarkActionBar
ActionBarActiviy
我想要的是什么:
我希望将其显示为个人图标
menu.xml文件
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/icnMenuWalletId"
android:icon="@drawable/wallet"
android:showAsAction="ifRoom"
android:title="WALLET">
</item>
<item
android:id="@+id/icnMenuTwoId"
android:icon="@drawable/notification"
android:showAsAction="ifRoom"
android:title="NOTIFICATIONS">
</item>
</menu>
Styles.xml
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- API 11 theme customizations can go here. -->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<!-- Application theme. -->
<style name="AppThemeSplash" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
</resources>
答案 0 :(得分:3)
您必须在menu.xml中编辑一行。只需编辑菜单项
的行android:showAsAction="always"
通过使用它,android将始终显示菜单项。如果菜单项不是必须在操作栏上显示,我们通常使用ifRoom。
答案 1 :(得分:2)
更改
android:showAsAction="ifRoom"
到
android:showAsAction="always"
ifRooom用于将项目移动到溢出菜单,如果没有空间容纳
答案 2 :(得分:0)
试试这个并确保您已将包名tools:context="com.abc.android.HomeActivityNew"
更改为您的包名称,希望它有所帮助
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.abc.android.HomeActivityNew" >
<item
android:id="@+id/icnMenuWalletId"
android:icon="@drawable/wallet"
android:showAsAction="always"
android:title="WALLET">
</item>
<item
android:id="@+id/icnMenuTwoId"
android:icon="@drawable/notification"
android:showAsAction="always"
android:title="NOTIFICATIONS">
</item>
</menu>