當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。