本文整理汇总了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();
}
});
}