Android:用于在选项卡之间切换的滑动手势和动画

发布于 2024-09-24 23:05:58 字数 266 浏览 4 评论 0原文

我确信这个问题已经在某个地方得到了回答,但我就是找不到它: 我有一个带有三个选项卡的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

誰ツ都不明白 2024-10-01 23:05:59

基本手势检测 - 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.

白芷 2024-10-01 23:05:59

现在,您可以在 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

叹沉浮 2024-10-01 23:05:59

必须完成两件事:

  • 将 Guesture 侦听对象注册到每个视图组
  • 在检测到 guesture 事件时,创建一个动画对象来移动此视图组,最后删除此视图组

请参阅 Blundell 在这篇文章中的回答:
如何以动画方式添加或删除 Android ListView 行

Two things has to be done:

  • Register Guesture listening object to every view group
  • On detecting guesture event, create an animation object to move this view group and at end, remove this view group

Please see the answer by Blundell in this post:
How to Animate Addition or Removal of Android ListView Rows

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文