㈠ 如何隱藏android WebView 縮放控制項
Android 3.0(11) 以上支持直接隱藏縮放控制項,做法如下:
1、確保android版本是3.0及以上
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="20" />
2、隱藏縮放控制項
webview.getSettings().setDisplayZoomControls(false);//設定縮放控制項隱藏
--------------------------------------------------------------------------
若要考慮兼容3.0以下版本則:
if(android.os.Build.VERSION.SDK_INT>=11){
this.getSettings().setDisplayZoomControls(false);
}else{
this.setZoomControlHide(this);
}
//Android 3.0(11) 以下使用以下方法:
//利用java的反射機制
public void setZoomControlHide(View view) {
try {
Class webview = Class.forName("android.webkit.WebView");
Method method = webview.getMethod("getZoomButtonsController");
zoomController = (ZoomButtonsController) method.invoke(this, null);
} catch (Exception e) {
e.printStackTrace();
}
}
㈡ android webview 怎麼放大縮小
Android:WebView如何設定支持縮放:需要對WebView和WebSettings做一下設定
webview.setVerticalScrollbarOverlay(true); //指定的垂直滾動條有疊加樣式
WebSettings settings = webview.getSettings();
settings.setUseWideViewPort(true);//設定支持viewport
settings.setLoadWithOverviewMode(true);
settings.setBuiltInZoomControls(true);
settings.setSupportZoom(true);//設定支持縮放
html界面meta標簽
<metaname="viewport"content="height= [pixel_value| "device-height"] ,width= [pixel_value| "device-width"] ,initial-scale=float_value,//初始縮放minimum-scale=float_value,//最小maximum-scale=float_value,//最大user-scalable= ["yes" | "no"]//是否允許用戶對頁面縮放 "/>
例如:<meta name="viewport" content="width=device-width,user-scalable=yes initial-scale=1.0, maximum-scale=2.0">-->設定支持縮放,最大兩倍縮放
㈢ android webview 放大縮小問題
額,太專業了,這種問題真的可以去問webview的客服郵箱,我都市這么乾的
㈣ Android webview無法縮放至屏幕大小
WebView無法放大縮小解決方案
http://blog.csdn.net/shuaihj/article/details/8808399
參考下這個看看能否解決
㈤ android webview怎麼禁止縮放
要支持縮放,肯定要先支持JavaScript,加如下代碼:
//支持JS
WebSettings settings = mWebView.getSettings();
settings.setJavaScriptEnabled(true);123123
重點來了,要想支持縮放,要加如下代碼支持
//支持屏幕縮放
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
我們怎樣去掉它呢,在Android3.0之後實現非常簡單,加一句代碼就可以了,如下代碼:
//不顯示webview縮放按鈕
settings.setDisplayZoomControls(false);
所以說,我們沒有必要兼容2.x了,就像iOS開發只兼容到IOS7版本就OK了,但是有的同學又說,我有強迫症,我就想兼容到2.x版本,其實解決方案網上都有了,這里用到了Java反射的知識,通過反射來獲取私有的屬性控制項mZoomButtonsController,然後就其setVisibility(View.GONE)隱藏就可以了,下面貼出代碼實現:
public void setZoomControlGone(View view){
Class classType;
Field field;
try {
classType = WebView.class;
field = classType.getDeclaredField("mZoomButtonsController");
field.setAccessible(true);
ZoomButtonsController mZoomButtonsController = new ZoomButtonsController(view);
mZoomButtonsController.getZoomControls().setVisibility(View.GONE);
try {
field.set(view, mZoomButtonsController);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
㈥ 關於 android WebView字體的放大縮小
不放圖片吶,就可以改字體。