从屏幕底部滑动/拖动 Android 视图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21784916/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Swipe/drag Android view from the bottom of the screen
提问by stanete
I want to do in my app a View that I can swipe from the bottom of the window (Images below explain it better).
我想在我的应用程序中做一个视图,我可以从窗口底部滑动(下面的图片更好地解释了它)。
I want the view to stop at certain point. The view must allow to swipe/drag it to the bottom again. Any idea or tip of how can I do that?
我希望视图在某个点停止。视图必须允许再次将其滑动/拖动到底部。关于我该怎么做的任何想法或提示?
采纳答案by Jon
I think you are in search of a ViewDragHelper
:
我想你正在寻找一个ViewDragHelper
:
API doc: https://developer.android.com/reference/android/support/v4/widget/ViewDragHelper.html
API 文档:https: //developer.android.com/reference/android/support/v4/widget/ViewDragHelper.html
How to use. This answer links to a sample project to show you how as well: ViewDragHelper: how to use it?
如何使用。这个答案链接到一个示例项目,向您展示如何使用: ViewDragHelper:如何使用它?
Dragging best practices:
拖动最佳实践:
回答by Nithish V
You can use the new material design pattern called Bottom Sheets. They do the exact thing that you want. They also support custom layouts for the view.
您可以使用称为底部表的新材料设计模式。他们做你想做的事情。它们还支持视图的自定义布局。