Android:用于在选项卡之间切换的滑动手势和动画
我确信这个问题已经在某个地方得到了回答,但我就是找不到它: 我有一个带有三个选项卡的 TabHost,每个选项卡包含不同的视图(不是活动)。我想要的是从右向左滑动手势,让当前视图向左滑出,下一个视图从右侧滑入,从而更改当前选项卡。因此,我希望通过手势(而不是仅通过单击选项卡)触发选项卡之间的切换,并且还希望在更改当前选项卡时显示动画。
我查看了 ViewFlipper 示例和教程,但找不到解释如何在选项卡之间滑动的示例和教程。
再次抱歉,如果之前已经回答过这个问题,我只是找不到它。
I'm sure this has been answered somewhere, already, but I just can't find it:
I have a TabHost with three tabs, each containing different views (not Activities). What I want is to make a swiping gesture from right to left and let the current view slide out to the left and the next view slide in from the right, thus changing the current tab. So, I want the switch between tabs to be triggered by a gesture (rather than only by clicking on the tab) and also want to show an animation when the current tab is changed.
I looked at the ViewFlipper examples and tutorials, but I can't find one that explains how to do this to slide between tabs.
Again, sorry if this has been answered before, I just can't find it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
基本手势检测 - stackoverflow
手势简介 - 移动设备
您必须使用 android 手势工具(您可以在模拟器中找到它)定义手势并实现手势监听器来监听手势事件。
Basic Gesture Detection - stackoverflow
Introduction to Gestures - mobile tuts
you have to definde your gestures with the android gesture tool (you can find it in the emulator) and implement a gesture listener to listen for gesture events.
现在,您可以在 Android SDK 兼容性库中找到对此行为的开箱即用支持。它不会使用 TabHost,但它支持您描述的行为: ViewPager
You can now find support for this behavior out-of-the-box in the Android SDK compatibility libs. It won't be using a TabHost, but it supports the behavior you describe: ViewPager
必须完成两件事:
请参阅 Blundell 在这篇文章中的回答:
如何以动画方式添加或删除 Android ListView 行
Two things has to be done:
Please see the answer by Blundell in this post:
How to Animate Addition or Removal of Android ListView Rows