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);