【问题标题】:Jetpack compose modal drawer opening gestureJetpack 撰写模态抽屉打开手势
【发布时间】:2021-08-24 11:56:29
【问题描述】:

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

【问题讨论】:

  • 这是known issue,请给它加星标,以便获得更多优先权。我能想到的唯一解决方法是获取源代码(包含所有内部组件,并且有很多)并根据您的需要进行修改
  • @PhilipDukhov 很高兴这是一个已知问题。是的,我会给它加星标。谢谢

标签: android android-jetpack-compose


【解决方案1】:

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

<?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)
        }
    }

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-07
    • 1970-01-01
    • 2021-10-04
    • 2022-01-23
    • 1970-01-01
    • 2022-11-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多