2017-03-19 73 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

相關問題