Je souhaite uniquement voir ma conception en tant que vue de navigation inférieure, j'ai donc essayé ce qui suit sur le fichier menu.xml en définissant tools: showIn = "bottom_navigation_view" mais il ne fait aucun effet sur mon onglet de vue de conception
Image de vue de menu dont je ne veux pas
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:showIn="bottom_navigation_view"> <item android:id="@+id/navigation_home" android:icon="@drawable/ic_home_black_24dp" android:title="@string/title_home" /> <item android:id="@+id/navigation_dashboard" android:icon="@drawable/ic_dashboard_black_24dp" android:title="@string/title_dashboard" /> <item android:id="@+id/navigation_notifications" android:icon="@drawable/ic_notifications_black_24dp" android:title="@string/title_notifications" /> </menu>
Alors, veuillez me suggérer une telle valeur de tools: showIn qui peut fonctionner.
3 Réponses :
Ajoutez ceci à votre mise en page et remplacez la valeur du menu.
<android.support.design.widget.BottomNavigationView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:attr/windowBackground" android:theme="@style/AppTheme" app:menu="@menu/navigation" android:layout_gravity="start" android:id="@+id/navigation" />
Oui, je l'ai fait mais je veux aussi afficher mon menu / navigation.xml en tant que vue de navigation du bas dans l'onglet de conception. Je veux des outils: des valeurs showIn grâce auxquelles je peux faire ça
android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="info.androidhive.bottomnavigation.MainActivity"> <FrameLayout android:id="@+id/frame_container" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> <android.support.design.widget.BottomNavigationView android:id="@+id/navigation" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:background="?android:attr/windowBackground" app:itemBackground="@color/bgBottomNavigation" android:foreground="?attr/selectableItemBackground" app:itemIconTint="@android:color/white" app:itemTextColor="@android:color/white" app:menu="@menu/navigation" />
Essayez ceci
activity_layout.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/action_home" android:icon="@drawable/ic_home_blue_48dp" android:title="Home" /> <item android:id="@+id/action_menu" android:icon="@drawable/ic_apps_black_24dp" android:title="Menu" /> <item android:id="@+id/action_msg" android:icon="@drawable/ic_chat_black_24dp" android:title="Message Inbox" /> </menu>
bottom_navigation_items.xml (menu)
<android.support.design.widget.BottomNavigationView android:id="@+id/navigation" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="@color/colorPrimary" app:itemIconTint="@drawable/bottom_nav_colors" app:itemTextColor="@drawable/bottom_nav_colors" app:menu="@menu/bottom_navigation_items"/>
Ce serait bien si vous pouviez expliquer comment cela résout le problème de l'aperçu de la conception dans bottom_navigation_items
qui ne s'affiche pas correctement.
essayez de le pointer vers
@ layout / yourlayout
et nonbottom_navigation_view
J'ai le même problème mais avec le
NavigationView
. J'ai essayé ce que vous avez dit @KaranMer mais cela n'a pas fonctionné.