Android 上 WebView 的 Google Reader 式优化

发布于 2024-12-07 04:39:36 字数 288 浏览 1 评论 0原文

我有一个应用程序,可以在 WebView 中显示博客文章的 html。然而,这些图像相当大,不适合屏幕。然而,当在 Android Google Reader 应用程序中查看帖子时,所有图像的宽度都会缩小以适合屏幕。

Android Google Reader 还将解析所有嵌入的 Youtube 和 Vimeo 嵌入内容,并将其替换为带有链接的缩略图,以便专用的 Youtube 播放器可以播放视频。

我该怎么做呢?我尝试使用 Jsoup 来匹配帖子中的所有图像并改变它们的宽度,但我不知道如何修改 Youtube 视频嵌入。

I have an app that displays the html of a blog post in a WebView. The images, however, are rather large and do not fit to the screen. When viewing the post in the Android Google Reader app, however, all of the images have their width reduced to fit the screen.

The Android Google Reader will also parse out all embedded Youtube and Vimeo embeds and replace them with thumbnails with links so the dedicated Youtube player can play the video instead.

How would I go about doing this? I've tried using Jsoup to match all the images in a post and alter their width, but I don't know how to go about modifying the Youtube video embeds.

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

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

发布评论

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

评论(1

偏爱自由 2024-12-14 04:39:37

要将嵌入的 Youtube 视频转换为缩略图,您可以使用 Mobilize.js 项目 中的 mobitube.js 代码来完成:

https://github.com/mobilizejs/mobilize.js/blob/master/js/mobitube.js

我也相信谷歌阅读器简单使用 CSS 覆盖调整图像大小。

Mobilize.js 还具有用于重写图像标签并为其执行“去浮动”操作的工具:

https://github.com/mobilizejs/mobilize.js/blob/master/js/mobilize.js#L2005

有关 defloat 算法的更多信息:

http://webandmobile.mfabrik.com/docs/web-and-mobile/user-manual/调整大小

如果您想在服务器端调整图像大小,这是第三方解决方案:

http://adaptive-images.com/

...尽管编写自己的图像调整大小代理从头开始服务器并不是那么具有挑战性。

For converting embed Youtube videos to thumbnails you can do it with mobitube.js code from Mobilize.js project:

https://github.com/mobilizejs/mobilize.js/blob/master/js/mobitube.js

Also I believe Google Reader simply resizes the images using CSS overrides.

Mobilize.js has also tools for rewriting image tags and perform "de-float" operation for them:

https://github.com/mobilizejs/mobilize.js/blob/master/js/mobilize.js#L2005

More about defloat algo:

http://webandmobile.mfabrik.com/docs/web-and-mobile/user-manual/resizing

If you want to resize images on the server-side this is a third party solution:

http://adaptive-images.com/

... though writing your own image resize proxy server from the scratch is not that challenging.

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