模仿“橡皮筋” Android 上图库中 iOS 的效果
我有一个 Gallery 类,在 Android 应用程序中显示一堆图像,但由于一次只显示一个图像,因此用户很难看到他们何时到达图库中的第一张或最后一张图像。有没有一种方法可以模仿iOS的“橡皮筋”效果,以便用户在拖动最后一个图像时看到一点空白空间,然后释放它,图像会弹回到视图的中心。这可以吗?
I've got a Gallery class showing a bunch of images in an Android app, but since only one image is ever displayed at a time, it is difficult for the user to see when they have reached the first or last image in the gallery. Is there a way to mimic iOS' "rubber band" effect, so that the user sees a bit of empty space when dragging the last image, and they release it, the image snaps back to the center of the view. Is this possible to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
研究
缓动方程http://www.gizma.com/easing/
释放屏幕时的 拖动最后一个图像,您可以使用它们将图像平滑地动画回到屏幕中央。
至于拖动最后一个图像时的效果,请对图像的位置使用倍增系数,这样手指越靠近屏幕一侧,图像就越不会跟随其移动。
Look into easing equations
http://www.gizma.com/easing/
when releasing the screen while been dragging the last image, you can use them to smoothly animate the image back to the center of the screen.
As for the effect while dragging the last image, use a multiplication factor on the position of the image so the more your finger reaches the side of the screen, the less the image will follow its movement.