本文整理匯總了Java中android.webkit.WebSettings.setDefaultZoom方法的典型用法代碼示例。如果您正苦於以下問題:Java WebSettings.setDefaultZoom方法的具體用法?Java WebSettings.setDefaultZoom怎麽用?Java WebSettings.setDefaultZoom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.webkit.WebSettings
的用法示例。
在下文中一共展示了WebSettings.setDefaultZoom方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import android.webkit.WebSettings; //導入方法依賴的package包/類
private void init() {
mWebView.setWebViewClient(webViewClient);
// mWebView.setWebChromeClient(chromeClient);
WebSettings settings = mWebView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
settings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
settings.setAppCacheEnabled(false);
settings.setSavePassword(false);
mWebView.loadUrl(mUrl);
}
示例2: initEvent
import android.webkit.WebSettings; //導入方法依賴的package包/類
private void initEvent() {
rl_back.setOnClickListener(this);
rl_option.setOnClickListener(this);
WebSettings settings = mWebView.getSettings();
//支持javascript
settings.setJavaScriptEnabled(true);
mWebView.addJavascriptInterface(new JsToJava(), "app");
//設置支持縮放
settings.setSupportZoom(true);//支持縮放
settings.setBuiltInZoomControls(true);//設置隱藏縮放按鈕
settings.setDisplayZoomControls(false);//隱藏原生的縮放按鈕
//設置自適應屏幕
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
//屏幕自適應網頁 解決低分辨率可能會顯示異常的問題
settings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
//自適應屏幕
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
//設置緩存機製
//settings.setAppCacheEnabled(true);
settings.setCacheMode(LOAD_NO_CACHE);
//運行webview通過URI獲取安卓文件
settings.setAllowFileAccess(true);
settings.setAllowFileAccessFromFileURLs(true);
settings.setAllowUniversalAccessFromFileURLs(true);
//支持自動加載圖片
settings.setLoadsImagesAutomatically(true);
mWebView.setWebViewClient(new MyWebViewClient());
mWebView.setWebChromeClient(new MyWebChromeClient());
mWebView.setOnLongClickListener(this);
mWebView.loadUrl(URL);
}
示例3: initWeb
import android.webkit.WebSettings; //導入方法依賴的package包/類
private void initWeb() {
WebSettings settings = mWebView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
mWebView.loadUrl("file:///android_asset/speedtest.html");
mWebView.setWebViewClient(new WebViewClient());
}
示例4: init
import android.webkit.WebSettings; //導入方法依賴的package包/類
private void init(Context context) {
mContext = context;
mLayout = new FrameLayout(context);
mBrowserFrameLayout = (FrameLayout) LayoutInflater.from(context)
.inflate(R.layout.common_custom_screen, null);
wv_imgbtn_back = (LinearLayout) mBrowserFrameLayout.findViewById(R.id.top_bar_linear_back);
wv_tv_title = (TextView) mBrowserFrameLayout.findViewById(R.id.top_bar_title);
mContentView = (FrameLayout) mBrowserFrameLayout
.findViewById(R.id.main_content);
mCustomViewContainer = (FrameLayout) mBrowserFrameLayout
.findViewById(R.id.fullscreen_custom_content);
frame_progress = (FrameLayout) mBrowserFrameLayout
.findViewById(R.id.frame_progress);
webview_tv_progress = (TextView) frame_progress
.findViewById(R.id.webview_tv_progress);
final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER);
mLayout.addView(mBrowserFrameLayout, COVER_SCREEN_PARAMS);
mWebChromeClient = new MyWebChromeClient();
setWebChromeClient(mWebChromeClient);
setWebViewClient(new MyWebViewClient());
WebSettings webSettings = this.getSettings();
webSettings.setJavaScriptEnabled(true); //開啟javascript
webSettings.setDomStorageEnabled(true); //開啟DOM
webSettings.setDefaultTextEncodingName("utf-8"); //設置編碼
// // web頁麵處理
webSettings.setAllowFileAccess(true);// 支持文件流
// webSettings.setSupportZoom(true);// 支持縮放
// webSettings.setBuiltInZoomControls(true);// 支持縮放
webSettings.setUseWideViewPort(true);// 調整到適合webview大小
webSettings.setLoadWithOverviewMode(true);// 調整到適合webview大小
webSettings.setDefaultZoom(ZoomDensity.FAR);// 屏幕自適應網頁,如果沒有這個,在低分辨率的手機上顯示可能會異常
webSettings.setRenderPriority(RenderPriority.HIGH);
//提高網頁加載速度,暫時阻塞圖片加載,然後網頁加載好了,在進行加載圖片
webSettings.setBlockNetworkImage(true);
//開啟緩存機製
webSettings.setAppCacheEnabled(true);
//根據當前網頁連接狀態
if(StrUtils.getAPNType(context)== StrUtils.WIFI){
//設置無緩存
webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
}else{
//設置緩存
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
}
mContentView.addView(this);
// 返回
wv_imgbtn_back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
closeAdWebPage();
}
});
}