首页 > 解决方案 > Jetpack 撰写模态抽屉打开手势

问题描述

我在模态抽屉布局上注意到的一点是手势不必从屏幕边缘开始。您只需在屏幕宽度的一半上做手势,它仍然会打开。这是现在的预期行为吗?或者这是一个问题?如果这是一个问题,任何人都知道有什么好的解决方法吗?谢谢

标签: androidandroid-jetpack-compose

解决方案


因为这个问题需要一段时间才能解决。我的解决方案是使用这样的视图绑定系统

<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

       <androidx.compose.ui.platform.ComposeView
            android:id="@+id/composeNavContent"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>


</androidx.drawerlayout.widget.DrawerLayout>

然后在我的作曲上

AndroidViewBinding(ActivityMainBinding::inflate) {
            // other content here

        composeNavContent.setContent {
            NavContent(navController = navController, drawerLayout)
        }
    }

此解决方法解决了我的抽屉具有正确手势(从边缘)的问题。直到这


推荐阅读