如何设置webview内容大小

更新时间:02-03 教程 由 思君 分享

如何设置webview内容大小?

android 如程序设置webview大小的方法为:

1、android自带的五种字体大小:

SMALLEST(50%),

SMALLER(75%),

NORMAL(100%),

LARGER(150%),

LARGEST(200%);

代码:webSettings.setTextSize(TextSize.LARGER);

2、android3。0以下的系统可以用下面的代码 :

public static void setScaleVsalue(View view, double size) {

Class classType;

Method method = null;

try {

classType = WebView.class;

for (Method item : classType.getDeclaredMethods()) {

if (item.getName().equals("setNewZoomScale")) {

method = item;

}

}

if (method != null) {

method.setAccessible(true);

method.invoke(view, new Object[] { (float) (size / 100.0),

true, true });

}

} catch (SecurityException e) {

e.printStackTrace();

} catch (IllegalAccessException e) {

e.printStackTrace();

} catch (IllegalArgumentException e) {

e.printStackTrace();

} catch (InvocationTargetException e) {

e.printStackTrace();

}

}

MyWebView.setScaleValue(mMyWebView,textSize);

声明:关于《如何设置webview内容大小》以上内容仅供参考,若您的权利被侵害,请联系13825271@qq.com
本文网址:http://www.25820.com/tutorial/14_2302360.html