手势导航:在ViewCompat类中缺少setSystemGestureExclusionRects()方法

问题描述 投票:1回答:1

Android具有View.setSystemGestureExclusionRects() API,可以在Android 10的指定区域禁用“后退”手势。此API是在API级别29中添加的,因此在使用它之前,我们必须检查SDK版本:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
   view.systemGestureExclusionRects = listOf(...)
}

The official documents says,即ViewCompat类还包含setSystemGestureExclusionRects()方法。这样可以避免检查SDK版本:

ViewCompat.setSystemGestureExclusionRects(...)

此方法必须从androidx.core:core:1.1.0-dev01开始可用。在我的项目中,我具有implementation 'androidx.core:core:1.1.0'依赖项。版本“ 1.1.0”晚于“ 1.1.0-dev01”,但是缺少ViewCompat.setSystemGestureExclusionRects()方法。为什么?

android gesture android-10.0
1个回答
1
投票
这似乎是一个文档错误。您将在1.2.0中找到它。例如,here is the ViewCompat from 1.2.0-rc01,当前最新版本(截至2020年1月10日)。它具有您想要的功能...尽管它几乎就是您的代码片段所显示的内容,仅在Java中:

ViewCompat

FWIW,我提交了1.2.0-rc01
© www.soinside.com 2019 - 2024. All rights reserved.