如何为核心 android 应用禁用 android 磨损回扫?

How to disable android wear back swipe for core android apps?

我是 运行 我 android 佩戴 Lg G 手表中的一个简单 android 应用程序。它不是 android 磨损应用程序。因此,当我尝试像这个答案 How to disable the android wear back swipe? 那样做时,我收到错误提示 "Error: No resource found that matches the given name Theme.DeviceDefault" 和 "Error: No resource found that matches the given name attr: android:windowSwipeToDismiss" 。我的目标 sdk 是 18。在这种情况下,有什么方法可以禁用向后滑动吗?

您应该使用 target sdk 21,它在所有 Android Wear 设备上。

遵循上一个问题的建议,即:

<style name="AppTheme" parent="@android:style/Theme.DeviceDefault.Light">
    <item name="android:windowSwipeToDismiss">false</item>
</style>

你需要 sdk 21,因为 windowSwipeToDismiss 还没有在 18 中引入。我相信这个 attr 是在 20 中引入的,但是由于所有磨损设备都有 api 级别 21,所以它没有意义使用较早的那个。喜欢使用最新的 API ;-)