首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何更改底部导航活动菜单布局文件的设计选项卡视图(工具:显示)

如何更改底部导航活动菜单布局文件的设计选项卡视图(工具:显示)
EN

Stack Overflow用户
提问于 2019-01-10 11:32:06
回答 3查看 458关注 0票数 6

我只想将我的设计看作是底部导航视图,所以我已经通过设置tools:showIn="bottom_navigation_view"menu.xml文件上尝试了以下操作,但是它对我的设计视图选项卡没有任何影响。

我不想要的菜单视图的图像

代码语言:javascript
复制
<?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>

因此,请建议我这样一个工具的价值:显示,它可以工作。

EN

回答 3

Stack Overflow用户

发布于 2019-01-10 11:37:32

将此添加到您的布局中并替换菜单的值。

代码语言:javascript
复制
<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"
    />
票数 0
EN

Stack Overflow用户

发布于 2019-01-10 12:11:31

代码语言:javascript
复制
 menu.xml folder should be created under res ⇒ menu folder.
代码语言:javascript
复制
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" />

票数 0
EN

Stack Overflow用户

发布于 2019-01-11 09:14:51

尝尝这个

activity_layout.xml

代码语言:javascript
复制
<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 (菜单)

代码语言:javascript
复制
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54127794

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档