Android 有没有 webview 的替代方案?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22459735/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there an alternative to webview?
提问by casolorz
I have an app which makes pretty heavy use of webview. My requirements are to be able to look at the html and to inject javascript into pages being loaded, even iframes. I've accomplished this with the webview that comes with android but it just isn't working great.
我有一个应用程序,它大量使用了 webview。我的要求是能够查看 html 并将 javascript 注入正在加载的页面,甚至是 iframe。我已经使用 android 附带的 webview 完成了这一点,但它的效果并不好。
So are there other projects out there that provide the same html5 browsing experience but are a bit more developer friendly? Would it maybe be possible to take the open source web view code and build my own or is that just a crazy idea?
那么是否有其他项目提供相同的 html5 浏览体验,但对开发人员更友好一些?是否有可能采用开源 Web 视图代码并构建我自己的代码,或者这只是一个疯狂的想法?
Thanks.
谢谢。
采纳答案by Ali Behzadian Nejad
Take a look at Crosswalk. As described in its web site:
看看人行横道。如其网站所述:
With the platform variations in the market you are forced to assume that every Android WebView works differently. There are differences in:
- Which JavaScript APIs are available
- Support and syntax for CSS properties
- How your application's interface is rendered …and plenty
more. You want to support as many versions of Android as possible, but it's frustrating and time consuming.
There's a better way. What if the only WebView you had to worry about was up to date with the latest version of Google Chromium? With Crosswalk, you can:
- Develop around device fragmentation
- Provide a feature rich experience on all Android 4.x devices
- Easily debug with Chrome DevTools Improve the performance of your HTML, CSS, and JavaScript
随着市场平台的变化,您不得不假设每个 Android WebView 的工作方式都不同。有以下区别:
- 哪些 JavaScript API 可用
- CSS 属性的支持和语法
- 你的应用程序界面是如何呈现的……还有很多
更多的。您希望支持尽可能多的 Android 版本,但这令人沮丧且耗时。
有更好的方法。如果您唯一需要担心的 WebView 是最新版本的 Google Chromium,该怎么办?使用 Crosswalk,您可以:
- 围绕设备碎片化开发
- 在所有 Android 4.x 设备上提供功能丰富的体验
- 使用 Chrome DevTools 轻松调试 提高 HTML、CSS 和 JavaScript 的性能
回答by Sam Panagrosso
In android 4.4, a new webview is introduced based off of chromium. However if you are developing for previous versions of android as well you can check out this library that is also based off of chromium https://github.com/mogoweb/chromium_webviewwith chromium, your webview will support HTML5, CSS3 and javascript
在 android 4.4 中,基于铬引入了一个新的 webview。但是,如果您也在为以前版本的 android 进行开发,您可以查看这个库,该库也基于铬https://github.com/mogoweb/chromium_webview和铬,您的 webview 将支持 HTML5、CSS3 和 javascript
回答by samridhgupta
You can also use Chrome Custom Tabsas a best option for handling third party Website on same app. And off course it is feature loaded. Like sharing chrome cookies, data saving option as with chrome
您还可以使用Chrome 自定义标签作为在同一应用程序上处理第三方网站的最佳选择。当然,它是功能加载的。像共享 chrome cookie、与 chrome 一样的数据保存选项