在 android honeycomb webview/webkit 中实现水平/垂直手指滑动滚动?

发布于 2024-12-08 19:38:44 字数 399 浏览 0 评论 0 原文

我计划实现基于 WebView 的 Honeycomb 平板电脑应用程序(因此,基本上它将是一个仅针对平板电脑制作的基于 HTML5 Web 的应用程序)。

我希望通过滑动手指来实现水平和垂直滚动。为了更好地理解,我创建了示例大纲。

Horizo​​ntal Scrolling by Swiping


此图显示了类似于 Honeycomb 的原生设置 Activity,左右页面可垂直滚动 通过滑动垂直滚动

欢迎任何类型的指南或资源。谢谢

I am planning to implement Honeycomb tablet application based on WebView (so, basically it'll be a HTML5 web based application made only for tablet).

I am looking to implement horizontal and vertical scrolling by swiping finger. For better understanding I created sample outline.

Horizontal Scrolling by Swiping


This image shows something similar to Honeycomb's native setting activity with left and right page vertically scrollable
Vertical Scrolling by Swiping

Any kind of guides or resources are welcome. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

余厌 2024-12-15 19:38:44

看看 iScroll

iScroll 4 完全重写了原始iScroll 代码。脚本开发开始是因为移动 webkit(在 iPhone、iPad、Android 上)不提供在固定宽度/高度元素内滚动内容的本机方法。这种不幸的情况导致任何网络应用程序都无法拥有 position:absolute 页眉和/或页脚以及内容的滚动中心区域。

虽然最新的 Android 版本支持此功能(尽管支持不是最佳),但 Apple 似乎不愿意向 div 添加一根手指滚动...

Take a look at iScroll:

iScroll 4 is a complete rewrite of the original iScroll code. The script development began because mobile webkit (on iPhone, iPad, Android) does not provide a native way to scroll content inside a fixed width/height element. This unfortunate situation prevents any web-app to have a position:absolute header and/or footer and a scrolling central area for contents.

While latest Android revisions are supporting this functionality (although support is not optimal), Apple seems reluctant to add one finger scrolling to divs...

铁憨憨 2024-12-15 19:38:44

这是我迄今为止发现的内容:

这取决于您想要如何实现滚动。如果您想附加滑动事件,这是使用众所周知的库实现的最简单方法:

我希望它有帮助。我仍在努力实现上下滚动,因为我不想等待滑动结束,而是尝试实现即时滚动反馈,使用 RAW JS 坐标非常接近,但并不令人满意。

Here is what I have found so far:

It depends on how you want to implement scrolling. If you want to attached swiping event, thats the easiest way to implement using well known libraries:

  • jqTouch - It has swipe left and right event which can be hooked to scroll left or right (it seems all the webkit based animations work only on iOS devices). Please note that project is still in beta and not highly active. EDIT: this is also part of Sencha Labs - who actively maintains Sencha Touch.
  • Sencha Touch - They have better support for almost everything in mobile and tablet. (Note: It's free for opensource apps but not for commercial apps - EDIT: they actually have commercial license. see their site for more info on licensing)
  • jQueryMobile - They are very stable (in RC1 as of now), and has swipe left and right event, but I could not find swipe up or down. If you just need swipe left right, tap, tap hold, then go with jQM. They have the best community support.
  • RAW JS - Finally, if you want something raw javascript, visit HTML5Rocks article to have better in-depth idea about how touch event works.

I hope it helps. I'm still struggling to implement scroll up down, since I don't want to wait for swipe to end, instead I am trying to implement instant scroll feedback, getting very close using RAW JS coordinates, but not satisfactory.

静若繁花 2024-12-15 19:38:44

Hammer JS 对我很有用:

http://eightmedia.github.io/hammer.js/

Hammer JS has been useful for me:

http://eightmedia.github.io/hammer.js/

神经暖 2024-12-15 19:38:44

对于 iScroll 的创建者来说,SwipeView 似乎是一个不错的专用替代方案。查看 演示 1演示 2

我还没有测试过,但我肯定会测试。因为演示在我的 iPad 上表现良好。

From the creators of iScroll, SwipeView seems a nice dedicated alternative. Have a look at demo 1 and demo 2.

I have not tested yet, but I will surely. Since demos behave well on my iPad.

倾城°AllureLove 2024-12-15 19:38:44

您可能会发现这个库非常有用: https://github.com/cubiq/2-way-iScroll

它处理垂直滚动和水平滑动的情况。

You might find this library quite useful: https://github.com/cubiq/2-way-iScroll

It handles the case of vertical scroll and horizontal swipe.

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