如何以编程方式打开(显示在屏幕中)NavigationView [英] How can I programmatically open (show in screen) NavigationView
本文介绍了如何以编程方式打开(显示在屏幕中)NavigationView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何以编程方式打开(显示在屏幕中)NavigationView?我找不到任何有用的功能.
How can I programmatically open (show in screen) NavigationView? I can't find any function what can be helpfull.
我有这个xml文件:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
//...
<android.support.design.widget.NavigationView
android:id="@+id/navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/nav_header"
app:itemTextColor="#333"
app:itemIconTint="#333"
app:menu="@menu/navigation_drawer_items" />
</android.support.v4.widget.DrawerLayout>
推荐答案
您需要参考DrawerLayout
You need have reference to DrawerLayout
drawerLayout.openDrawer();
drawerLayout.closeDrawer();
使用openDrawer和closeDrawer更改菜单可见性
use openDrawer and closeDrawer to change menu visibility
这篇关于如何以编程方式打开(显示在屏幕中)NavigationView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文