How to change the view of Design Tab of menu layout file for Bottom Navigation Activity (tools:showIn)
Asked Answered
C

3

6

I only want to see my design as bottom navigation view so I had tried the following on menu.xml file by setting tools:showIn="bottom_navigation_view" but it is not making any effect to my design view tab

Image of menu view which I don't want

enter image description here

<?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>

So please suggest me such a value of tools:showIn which can work.

Ceramic answered 10/1, 2019 at 11:32 Comment(3)
try pointing it to @layout/yourlayout not bottom_navigation_viewSelfinduced
I have the same issue but with the NavigationView. I tried what you said @KaranMer but it didn't work.Welsh
You can use tools:showIn="navigation_view" as an alternativeAusgleich
S
0

Add this to your layout and replace value of 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"
    />
Saraisaraiya answered 10/1, 2019 at 11:37 Comment(1)
Ya I did it but I also want to view my menu/navigation.xml as bottom navigation view in design tab. I want tools:showIn values through which I can do thatCeramic
P
0
 menu.xml folder should be created under res ⇒ menu folder.

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" />

Photothermic answered 10/1, 2019 at 12:11 Comment(0)
T
0

Try this

activity_layout.xml

<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"/>

bottom_navigation_items.xml (menu)

<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>
Tamanaha answered 11/1, 2019 at 9:14 Comment(1)
It would be nice if you could explain how this solves the problem of the design preview within bottom_navigation_items not displaying properly.Welsh

© 2022 - 2024 — McMap. All rights reserved.