首页 > 解决方案 > setDrawerLockMode 的 XML 替代方案

问题描述

我想将DrawerLayout的锁定模式设置为,DrawerLayout.LOCK_MODE_LOCKED_CLOSED但我想使用 XML 属性而不是以编程方式进行。有点像下面的无效 XML:

<androidx.drawerlayout.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:lock_mode = "close"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

注意: XML 代码android:lock_mode = "close"不存在。

标签: androidxmldrawerlayoutnavigationviewandroid-navigationview

解决方案


推荐阅读