WebView自适用屏幕
来源:互联网 发布:淘宝用户冻结无法登陆 编辑:程序博客网 时间:2024/06/10 01:16
可以通过设置LayoutAlgorithm的布局模式来控制WebView
SDK给的方法解释:Sets the underlying layout algorithm. This will cause a relayout of the WebView. The default is{@link LayoutAlgorithm#NARROW_COLUMNS}.
LayoutAlgorithm有三种模式可以选择:
1、LayoutAlgorithm.NARROW_COLUMNS 列宽尽可能的窄,但页面很大的话还是会超过手机的屏幕(默认方式)
2、LayoutAlgorithm.SINGLE_COLUMN 只有一列,宽度与手机屏宽度一样
3、LayoutAlgorithm.NORMAL 正常显示,WebView不作处理
可以设置mWebView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);使H5页面适用手机屏幕大小。
还有人说可以通过一下方法设置自适应
mWebView.getSettings().setUseWideViewPort(true);
mWebView.getSettings().setLoadWithOverviewMode(true);
我试了,但是没有达到预期的效果
SDK对这两个方法的描述是这样的:
/**
* Sets whether the WebView should enable support for the "viewport"
* HTML meta tag or should use a wide viewport.
* When the value of the setting is false, the layout width is always set to the
* width of the WebView control in device-independent (CSS) pixels.
* When the value is true and the page contains the viewport meta tag, the value
* of the width specified in the tag is used. If the page does not contain the tag or
* does not provide a width, then a wide viewport will be used.
*
* @param use whether to enable support for the viewport meta tag
*/
public synchronized void setUseWideViewPort(boolean use) {
throw new MustOverrideException();
}
/**
* Sets whether the WebView loads pages in overview mode, that is,
* zooms out the content to fit on screen by width. This setting is
* taken into account when the content width is greater than the width
* of the WebView control, for example, when {@link #getUseWideViewPort}
* is enabled. The default is false.
*/
public void setLoadWithOverviewMode(boolean overview) {
throw new MustOverrideException();
}
这里没有深入研究。希望大神指导
- WebView自适用屏幕
- 解决窗口自适用大小
- WebView自适应屏幕宽度
- WebView自适应屏幕大小
- WebView适应屏幕
- Webview 自适应屏幕大小
- WebView自适应屏幕大小
- WebView自适应屏幕
- Webview自适应屏幕
- Webview 自适应屏幕
- webview自适应屏幕
- Webview自适应屏幕
- android webview自适应屏幕
- WebView图片自适应屏幕
- WebView图片自适应屏幕
- webView网页自适应屏幕
- webView自适应屏幕大小
- WebView图片自适应屏幕
- iOS学习——Object-C模拟类变量
- HTTP协议定义的缓存机制
- Spring mvc注解说明
- socket阻塞与非阻塞,同步与异步、I/O模型
- iOS学习笔记(二.iOS程序执行流程)
- WebView自适用屏幕
- Web未来设计发展的七大趋势
- pom.xml常用元素知识
- php读文件——将服务端的文件读出来显示在web页面
- ubuntu12.04 + fuerte ROS下安装xtion pro live 显示图像
- HDU 5017 Ellipsoid(模拟退火)
- sqlite3 数据库命令操作
- 几个ie6样式兼容性:1px高的块容器、PNG透明图像、负边距时后遮盖前、边框不显示等问题
- Hibernate、MyBatis的比较