java我想删除NavigationView布局上的一个栏
我创建了一个NavigationView,它成功了
但它有一个小错误。
我希望我可以删除这个绿色和灰色的酒吧。(当我创建NavigationView时,它会出现…
我不知道怎么做
这是我的代码:
xml:
<安卓x.drawerlayout.widget.DrawerLayout
安卓:id="@+id/drawerLayout"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:fitsSystemWindows="true"
>
<com.google.安卓.material.navigation.NavigationView
安卓:id="@+id/nav_view"
安卓:layout_width="240dp"
安卓:layout_height="match_parent"
安卓:layout_gravity="start"
安卓:fitsSystemWindows="true"
app:menu="@menu/activity_miaoli_menu"
/>
</安卓x.drawerlayout.widget.DrawerLayout>
菜单:
<menu xmlns:安卓="http://schemas.安卓.com/apk/res/安卓">
<group 安卓:checkableBehavior="single">
<item
安卓:id="@+id/nav_home"
安卓:icon="@drawable/ic_menu_camera"
安卓:title="@string/menu_home" />
<item
安卓:id="@+id/nav_gallery"
安卓:icon="@drawable/ic_menu_gallery"
安卓:title="@string/menu_gallery" />
</group>
</menu>
导航。爪哇
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
navigationView = (NavigationView) findViewById(R.id.nav_view);
ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this,
drawerLayout, toolbar, R.string.open, R.string.close);
drawerLayout.addDrawerListener(actionBarDrawerToggle);
actionBarDrawerToggle.syncState();
navigationView.bringToFront();
有人能帮我吗? 先谢谢你
# 1 楼答案
在布局中为坐标布局的根子级添加布局\u行为
# 2 楼答案
删除app:menu=“@menu/activity\u miaoli\u menu”这一行并制作如下所示的自定义导航抽屉,为每个项目制作一个布局