2017-03-19 72 views
1

我试图在我的Android应用程序中实现选项卡样式菜单栏,但是我添加到菜单中的任何<item />未在预览中显示(请参阅下图)。Android项目不在菜单中出现

预览菜单/ menu_navigation.xml的:

(包含在菜单中的<item /> /未显示menu_navigation.xml)

item not displayed in Android Preview

菜单/ menu_navigation.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/bMenu" 
    android:title="@string/app_name" 
    android:icon="@drawable/ic_home" 
    app:showAsAction="ifRoom" 
    /> 

activity_main.xml中:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:design="http://schemas.android.com/apk/res-auto" 
tools:context="com.engineeringeric.parkerapp.MainActivity"> 

<android.support.design.widget.BottomNavigationView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom" 
    design:menu="@menu/menu_navigation"> 
</android.support.design.widget.BottomNavigationView> 

+0

请张贴您的代码供我们分析。谢谢。 – statosdotcom

+0

你好,没有为所描述的UI元素编写的Java代码,因为我不相信只需要Java来设计/显示标签UI。上面提供了我正在使用的所有xml。谢谢。 –

+0

在您的预览窗口中,模拟手机为什么选中“无操作栏?”。也许这......因为它迫使使用没有酒吧的风格......并且你想要显示生活在标签栏中的标签...... – statosdotcom

回答

1

在预览窗口,模拟手机,变“无操作栏”不管是什么就可以了,因为这是指示预览窗口隐藏菜单。

或许您的菜单并未出现在您的预览窗口中,而不是真实的情况下,即在您的手机或模拟器上,也许您的菜单显示出来。

把你的应用程序运行在你的手机或模拟器上,看看我是否正确。

+0

很高兴工作!保持! – statosdotcom

相关问题