
通常,“滑动到关闭”手势(从左向右滑动)会关闭应用程序(活动),但是您能想象出有图片或地图的情况,您需要在应用程序中平移.从左到右的平移始终关闭应用程序.
应该有一个Google在https://developer.android.com/training/wearables/ui/exit.html#swipe-to-dismiss上描述的解决方案.
If you want the user to go down the back stack,you can wrap the vIEw in a SwipedismissFrameLayout object,which supports edge swipe. Edge
swipe is enabled when the vIEw or its children returns true from a
canScrollHorizontally() call. Edge swipe enables the user to dismiss
the vIEw by swiPing from the leftmost sIDe of the screen (currently
set to 10% of the screen wIDth) and not just anywhere in the vIEw.
这是在适用于AndroID的谷歌地图应用中实现的.如果您开始非常靠近左边缘滑动,应用程序将关闭.它被称为“边缘滑动”.
问题是canScrollHorizontally()必须返回true并且我无法正确设置此视图属性 – 它始终为false. https://developer.android.com/reference/android/support/wearable/view/SwipeDismissFrameLayout.html
布局文件.
<?xml version="1.0" enCoding="utf-8"?><androID.support.wearable.vIEw.SwipedismissFrameLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:tools="http://schemas.androID.com/tools" androID:ID="@+ID/swipe_dismiss_root" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:isScrollContainer="true" androID:nestedScrollingEnabled="true" tools:context="jhettler.wearmaps.MainActivity" tools:deviceids="wear"> <relativeLayout androID:ID="@+ID/map_area" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:fadeScrollbars="false" androID:isScrollContainer="true" androID:nestedScrollingEnabled="true"> </relativeLayout></androID.support.wearable.vIEw.SwipedismissFrameLayout>
我不想实现像dismissOverlayVIEw这样的弃用类,并使用电源按钮退出应用程序.
任何想法或例子怎么做?
谢谢!
解决方法 尝试使用以下代码禁用滑动到解雇:<resources> <style name="Apptheme" parent="@androID:style/theme.DeviceDefault"> <item name="androID:windowswipetodismiss">false</item> </style></resources>
disabling swipe-to-dismiss generally is not recommended because the user expects to dismiss any screen with a swipe. In an exceptional case,you can set windowswipetodismiss to false and the user would press the power button to exit your app.
这可以在AndroID Wear 2.0的Behavior Changes文档中找到.重新引入Swipe-to-dismiss,电源按钮返回Watch Face以及AndroID Wear 2.0的其他更改等内容在此处进行了讨论.
希望这可以帮助.
总结以上是内存溢出为你收集整理的wear-os – 边缘滑动和应用程序退出Android Wear 2.0全部内容,希望文章能够帮你解决wear-os – 边缘滑动和应用程序退出Android Wear 2.0所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)