当前位置: 首页>>代码示例>>Java>>正文


Java WebSettings.setDisplayZoomControls方法代码示例

本文整理汇总了Java中android.webkit.WebSettings.setDisplayZoomControls方法的典型用法代码示例。如果您正苦于以下问题:Java WebSettings.setDisplayZoomControls方法的具体用法?Java WebSettings.setDisplayZoomControls怎么用?Java WebSettings.setDisplayZoomControls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.webkit.WebSettings的用法示例。


在下文中一共展示了WebSettings.setDisplayZoomControls方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint({"AddJavascriptInterface", "SetJavaScriptEnabled"})
private void init() {
    setClickable(false);
    setFocusable(false);

    setHorizontalScrollBarEnabled(false);

    WebSettings settings = getSettings();
    settings.setDefaultFontSize(14);
    settings.setSupportZoom(false);
    settings.setBuiltInZoomControls(false);
    settings.setDisplayZoomControls(false);
    settings.setJavaScriptEnabled(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        addJavascriptInterface(new OnWebViewImageListener() {
            @Override
            @JavascriptInterface
            public void showImagePreview(String bigImageUrl) {
                if (bigImageUrl != null && !StringUtils.isEmpty(bigImageUrl)) {
                    ImageGalleryActivity.show(getContext(), bigImageUrl);
                }
            }
        }, "mWebViewImageListener");
    }
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:27,代码来源:OWebView.java

示例2: initWebView

import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint({"JavascriptInterface", "SetJavaScriptEnabled"})
public static void initWebView(WebView webView) {
    WebSettings settings = webView.getSettings();
    settings.setDefaultFontSize(14);
    settings.setJavaScriptEnabled(true);
    settings.setSupportZoom(false);
    settings.setBuiltInZoomControls(false);
    int sysVersion = Build.VERSION.SDK_INT;
    if (sysVersion >= 11) {
        settings.setDisplayZoomControls(false);
    } else {
        ZoomButtonsController zbc = new ZoomButtonsController(webView);
        zbc.getZoomControls().setVisibility(View.GONE);
    }
    //webView.setWebViewClient(UiUtil.getWebViewClient());
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:17,代码来源:UIHelper.java

示例3: init

import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void init(Context context) {
    // 顶部显示的进度条
    mProgressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
    mProgressBar.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 7, 0, 0));
    Drawable drawable = context.getResources().getDrawable(R.drawable.layer_web_progress_bar);
    mProgressBar.setProgressDrawable(drawable);
    addView(mProgressBar);

    WebSettings webSettings = this.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setSupportZoom(true);   // 是能放大缩小
    webSettings.setUseWideViewPort(true);
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDisplayZoomControls(false);//隐藏
    webSettings.setDomStorageEnabled(true);
    webSettings.setSupportMultipleWindows(true);
    //webSettings.setUseWideViewPort(true);
    this.setWebViewClient(mWebViewClientBase);
    this.setWebChromeClient(mWebChromeClientBase);
    setDownloadListener(new DownloadListener());
    this.onResume();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:CustomWebView.java

示例4: initWebView

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebView() {
        WebSettings webSettings = webView.getSettings();
//        webSettings.setJavaScriptEnabled(true);

        webSettings.setUseWideViewPort(true); //将图片调整到适合webview的大小
        webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕的大小

        webSettings.setSupportZoom(true); //支持缩放,默认为true。是下面那个的前提。
        webSettings.setBuiltInZoomControls(true); //设置内置的缩放控件。若为false,则该WebView不可缩放
        webSettings.setDisplayZoomControls(false); //隐藏原生的缩放控件

        webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //关闭webview中缓存
        webSettings.setAllowFileAccess(true); //设置可以访问文件
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口
        webSettings.setLoadsImagesAutomatically(true); //支持自动加载图片
        webSettings.setDefaultTextEncodingName("utf-8");//设置编码格式

    }
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:19,代码来源:WebActivity.java

示例5: initWebView

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebView(String url) {
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setGeolocationEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setDatabaseEnabled(true);
    webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    webSettings.setAllowFileAccess(true);
    webSettings.setAppCacheEnabled(true);
    webSettings.setDisplayZoomControls(false);
    if (Build.VERSION.SDK_INT >= 21) {
        webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }
    mWebView.setWebChromeClient(new MyWebChromeClient());

    mWebView.loadUrl(url);
}
 
开发者ID:woxingxiao,项目名称:GracefulMovies,代码行数:22,代码来源:WebActivity.java

示例6: loadImage

import android.webkit.WebSettings; //导入方法依赖的package包/类
public void loadImage(@NonNull String url, boolean isSvg) {
    WebSettings settings = getSettings();
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    settings.setSupportZoom(true);
    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);
    String html;
    if (isSvg) {
        html = url;
    } else {
        html = "<html><head><style>img{display: inline; height: auto; max-width: 100%;}</style></head><body>" +
                "<img src=\"" + url + "\"/></body></html>";
    }
    Logger.e(html);
    loadData(html, "text/html", null);
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:18,代码来源:PrettifyWebView.java

示例7: initSettings

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initSettings(){
    WebSettings webSettings = this.getSettings();

    webSettings.setJavaScriptEnabled(true);

    webSettings.setDomStorageEnabled(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setUseWideViewPort(true);

    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);

    webSettings.setSupportZoom(false);
    webSettings.setBuiltInZoomControls(false);
    webSettings.setDisplayZoomControls(false);

    webSettings.setDefaultTextEncodingName("UTF-8");

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        webSettings.setAllowFileAccessFromFileURLs(true);
        webSettings.setAllowUniversalAccessFromFileURLs(true);
    }
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setAcceptThirdPartyCookies(this,true);
    }
    setWebViewDefaultCacheMode();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        webSettings.setMixedContentMode(
                WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
    }
    setCachePath();

}
 
开发者ID:yale8848,项目名称:CacheWebView,代码行数:35,代码来源:CacheWebView.java

示例8: createWebView

import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
public WebView createWebView(WebView webView) {

    //WebView.setWebContentsDebuggingEnabled(true);
    //不能横向滚动
    webView.setHorizontalScrollBarEnabled(false);
    //不能纵向滚动
    webView.setVerticalScrollBarEnabled(false);
    //允许截图
    webView.setDrawingCacheEnabled(true);
    //屏蔽长按事件
    webView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            return true;
        }
    });
    //初始化WebSettings
    final WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    final String ua = settings.getUserAgentString();
    settings.setUserAgentString(ua + "Latte");
    //隐藏缩放控件
    settings.setBuiltInZoomControls(false);
    settings.setDisplayZoomControls(false);
    //禁止缩放
    settings.setSupportZoom(false);
    //文件权限
    settings.setAllowFileAccess(true);
    settings.setAllowFileAccessFromFileURLs(true);
    settings.setAllowUniversalAccessFromFileURLs(true);
    settings.setAllowContentAccess(true);
    //缓存相关
    settings.setAppCacheEnabled(true);
    settings.setDomStorageEnabled(true);
    settings.setDatabaseEnabled(true);
    settings.setCacheMode(WebSettings.LOAD_DEFAULT);

    return webView;
}
 
开发者ID:remerber,项目名称:FastEc,代码行数:41,代码来源:WebViewInitializer.java

示例9: initWebSettings

import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
public void initWebSettings(WebSettings webSettings){
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setSupportZoom(true);
    webSettings.setDisplayZoomControls(false);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setUserAgentString("ios");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }
}
 
开发者ID:flyer88,项目名称:EasyJsBridge,代码行数:14,代码来源:MainActivity.java

示例10: setDiffFileSource

import android.webkit.WebSettings; //导入方法依赖的package包/类
public void setDiffFileSource(@NonNull String source, boolean wrap) {
    if (StringUtils.isBlank(source)) return;
    WebSettings settings = getSettings();
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
    setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    settings.setSupportZoom(true);
    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);
    String page = HtmlHelper.generateDiffHtml(source, AppUtils.isNightMode(),
            getCodeBackgroundColor(), wrap);
    loadPage(page);
}
 
开发者ID:ThirtyDegreesRay,项目名称:OpenHub,代码行数:13,代码来源:CodeWebView.java

示例11: setupWebView

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void setupWebView(WebSettings settings) {
    if (settings == null) {
        return;
    }

    settings.setAppCacheEnabled(true);
    settings.setAllowFileAccess(true);
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setSupportZoom(true);
    settings.setDisplayZoomControls(true);
}
 
开发者ID:Sugarya,项目名称:Closet,代码行数:14,代码来源:BasicWebFragment.java

示例12: initWebSettings

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebSettings() {
  WebSettings settings = mWebView.getSettings();
  //支持获取手势焦点
  mWebView.requestFocusFromTouch();
  //支持JS
  settings.setJavaScriptEnabled(true);
  //支持插件
  settings.setPluginState(WebSettings.PluginState.ON);
  //设置适应屏幕
  settings.setUseWideViewPort(true);
  settings.setLoadWithOverviewMode(true);
  //支持缩放
  settings.setSupportZoom(false);
  //隐藏原生的缩放控件
  settings.setDisplayZoomControls(false);
  //支持内容重新布局
  settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
  settings.supportMultipleWindows();
  settings.setSupportMultipleWindows(true);
  //设置缓存模式
  settings.setDomStorageEnabled(true);
  settings.setDatabaseEnabled(true);
  settings.setCacheMode(WebSettings.LOAD_DEFAULT);
  settings.setAppCacheEnabled(true);
  settings.setAppCachePath(mWebView.getContext().getCacheDir().getAbsolutePath());

  //设置可访问文件
  settings.setAllowFileAccess(true);
  //当webview调用requestFocus时为webview设置节点
  settings.setNeedInitialFocus(true);
  //支持自动加载图片
  if (Build.VERSION.SDK_INT >= 19) {
    settings.setLoadsImagesAutomatically(true);
  } else {
    settings.setLoadsImagesAutomatically(false);
  }
  settings.setNeedInitialFocus(true);
  //设置编码格式
  settings.setDefaultTextEncodingName("UTF-8");
}
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:41,代码来源:WebViewUI.java

示例13: setupWebSettings

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void setupWebSettings() {
    WebSettings settings = mWebView.getSettings();
    settings.setBuiltInZoomControls(true);
    //settings.setLoadWithOverviewMode(true);
    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setDomStorageEnabled(true);
    settings.setNeedInitialFocus(true);
    settings.setDisplayZoomControls(false);
    mWebView.setWebChromeClient(new MyWebChromeClient());
    mWebView.setWebViewClient(new MyWebViewClient());

}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:14,代码来源:CodeMirrorEditor.java

示例14: initWebView

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebView() {
    WebSettings ws = mWebView.getSettings();
    // 网页内容的宽度是否可大于WebView控件的宽度
    ws.setLoadWithOverviewMode(false);
    // 保存表单数据
    ws.setSaveFormData(true);
    // 是否应该支持使用其屏幕缩放控件和手势缩放
    ws.setSupportZoom(true);
    ws.setBuiltInZoomControls(true);
    ws.setDisplayZoomControls(false);
    // 启动应用缓存
    ws.setAppCacheEnabled(true);
    // 设置缓存模式
    ws.setCacheMode(WebSettings.LOAD_DEFAULT);
    // setDefaultZoom  api19被弃用
    // 设置此属性,可任意比例缩放。
    ws.setUseWideViewPort(true);
    // 缩放比例 1
    mWebView.setInitialScale(1);
    // 告诉WebView启用JavaScript执行。默认的是false。
    ws.setJavaScriptEnabled(true);
    //  页面加载好以后,再放开图片
    ws.setBlockNetworkImage(false);
    // 使用localStorage则必须打开
    ws.setDomStorageEnabled(true);
    // 排版适应屏幕
    ws.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
    // WebView是否支持多个窗口。
    ws.setSupportMultipleWindows(true);
    // webview从5.0开始默认不允许混合模式,https中不能加载http资源,需要设置开启。
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ws.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }
    /** 设置字体默认缩放大小(改变网页字体大小,setTextSize  api14被弃用)*/
    ws.setTextZoom(100);
    mWebView.setWebViewClient(new MyWebViewClient());
    mWebView.setWebChromeClient(webChromeClient = new MyWebChromeClient());
    mWebView.loadUrl(url);
}
 
开发者ID:yangchong211,项目名称:YCUtils,代码行数:40,代码来源:KnowledgeOtherFragment.java

示例15: init

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void init() {
    WebSettings settings = getSettings();
    settings.setUseWideViewPort(true);
    settings.setBuiltInZoomControls(true);
    settings.setLoadWithOverviewMode(true);
    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setDomStorageEnabled(true);
    settings.setDisplayZoomControls(false);
    setWebViewClient(new WebViewClient());
    setWebChromeClient(new WebChromeClient());
}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:13,代码来源:JsWebView.java


注:本文中的android.webkit.WebSettings.setDisplayZoomControls方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。