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) {
} catch (IllegalArgumentException e) {
} catch (InvocationTargetException e) {
MyWebView.setScaleValue(mMyWebView,textSize);
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);