當前位置: 首頁>>代碼示例>>Java>>正文


Java WebSettings.setSupportZoom方法代碼示例

本文整理匯總了Java中android.webkit.WebSettings.setSupportZoom方法的典型用法代碼示例。如果您正苦於以下問題:Java WebSettings.setSupportZoom方法的具體用法?Java WebSettings.setSupportZoom怎麽用?Java WebSettings.setSupportZoom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.webkit.WebSettings的用法示例。


在下文中一共展示了WebSettings.setSupportZoom方法的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: initData

import android.webkit.WebSettings; //導入方法依賴的package包/類
@Override
protected void initData() {
    WebSettings settings = mWebView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setLoadWithOverviewMode(true);
    settings.setAppCacheEnabled(true);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    settings.setSupportZoom(true);
    mWebView.setWebChromeClient(new ChromeClient());
    mWebView.setWebViewClient(new LoveClient());
    mWebView.loadUrl(mUrl);

    mTextSwitcher.setFactory(() -> {
        TextView textView = new TextView(this);
        textView.setTextAppearance(this, R.style.WebTitle);
        textView.setSingleLine(true);
        textView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
        textView.postDelayed(() -> textView.setSelected(true), 1738);
        return textView;
    });
    mTextSwitcher.setInAnimation(this, android.R.anim.fade_in);
    mTextSwitcher.setOutAnimation(this, android.R.anim.fade_out);
    if (mTitle != null) setTitle(mTitle);
}
 
開發者ID:weixianshishen,項目名稱:BeautifulGirls,代碼行數:25,代碼來源:WebActivity.java

示例3: initViews

import android.webkit.WebSettings; //導入方法依賴的package包/類
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void initViews() {
    setTitle(getIntent().getStringExtra(EXTRA_TITLE));

    WebSettings settings = mWebView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setLoadWithOverviewMode(true);
    settings.setAppCacheEnabled(true);
    settings.setSupportZoom(true);
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);

    mUrl = getIntent().getStringExtra(EXTRA_URL);
    mWebView.loadUrl(mUrl);
    mWebView.setWebChromeClient(new WebChromeClient());
    mWebView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return false;
        }
    });
}
 
開發者ID:Shuanghua,項目名稱:LikeGank,代碼行數:25,代碼來源:WebViewActivity.java

示例4: 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

示例5: setupWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void setupWebView() {
    WebSettings settings = mWvWebview.getSettings();

    settings.setJavaScriptEnabled(true);
    settings.setSupportZoom(false);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    settings.setDomStorageEnabled(true);

    WebViewClient webViewClient = new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
            view.loadUrl(String.valueOf(request.getUrl()));
            return true;
        }
    };

    mWvWebview.setWebViewClient(webViewClient);
}
 
開發者ID:coderwjq,項目名稱:ZhaZhaShop,代碼行數:20,代碼來源:WebViewActivity.java

示例6: setWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void setWebView()
{

    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);//如果訪問的頁麵中要與Javascript交互,則webview必須設置支持Javascript
    webSettings.setUseWideViewPort(true); //將圖片調整到適合webview的大小
    webSettings.setLoadWithOverviewMode(true); // 縮放至屏幕的大小
    webSettings.setSupportZoom(true); //支持縮放,默認為true。是下麵那個的前提。
    webSettings.setBuiltInZoomControls(true); //設置內置的縮放控件。若為false,則該WebView不可縮放
    webSettings.setDisplayZoomControls(false); //隱藏原生的縮放控件
    webSettings.setAllowFileAccess(true); //設置可以訪問文件
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true); //支持通過JS打開新窗口
    webSettings.setLoadsImagesAutomatically(true); //支持自動加載圖片
    webSettings.setDefaultTextEncodingName("utf-8");//設置編碼格式
    webSettings.setDomStorageEnabled(true);
    mWebView.setWebViewClient(new WebViewClient());
}
 
開發者ID:XndroidDev,項目名稱:Xndroid,代碼行數:18,代碼來源:WebViewFragment.java

示例7: 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

示例8: b

import android.webkit.WebSettings; //導入方法依賴的package包/類
@SuppressLint({"SetJavaScriptEnabled"})
private void b() {
    this.i.setVerticalScrollBarEnabled(false);
    this.i.setHorizontalScrollBarEnabled(false);
    this.i.setWebViewClient(new FbWebViewClient());
    this.i.setWebChromeClient(this.mChromeClient);
    this.i.clearFormData();
    WebSettings settings = this.i.getSettings();
    settings.setSavePassword(false);
    settings.setSaveFormData(false);
    settings.setCacheMode(-1);
    settings.setNeedInitialFocus(false);
    settings.setBuiltInZoomControls(true);
    settings.setSupportZoom(true);
    settings.setRenderPriority(RenderPriority.HIGH);
    settings.setJavaScriptEnabled(true);
    if (!(this.c == null || this.c.get() == null)) {
        settings.setDatabaseEnabled(true);
        settings.setDatabasePath(((Context) this.c.get()).getApplicationContext().getDir
                ("databases", 0).getPath());
    }
    settings.setDomStorageEnabled(true);
    this.jsBridge.a(new JsListener(), "sdk_js_if");
    this.i.loadUrl(this.e);
    this.i.setLayoutParams(a);
    this.i.setVisibility(4);
    this.i.getSettings().setSavePassword(false);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:29,代碼來源:TDialog.java

示例9: configWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
protected void configWebView() {
    mWebView = new WebView(getApplicationContext());
    mWebViewContainer.addView(mWebView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    WebSettings settings = mWebView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDefaultTextEncodingName("UTF-8");
    settings.setSupportZoom(false);
    settings.setPluginState(WebSettings.PluginState.ON);
    mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
}
 
開發者ID:Zweihui,項目名稱:Aurora,代碼行數:11,代碼來源:BaseWebActivity.java

示例10: 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

示例11: 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);
    }
 
開發者ID:pre-dem,項目名稱:pre-dem-android,代碼行數:16,代碼來源:WebViewActivity.java

示例12: 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

示例13: setWebViewSettings

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void setWebViewSettings() {
        WebSettings webSettings = webView.getSettings();
        // 打開頁麵時, 自適應屏幕
        webSettings.setUseWideViewPort(true); //將圖片調整到適合webview的大小
        webSettings.setLoadWithOverviewMode(true); // 縮放至屏幕的大小
        // 便頁麵支持縮放
        webSettings.setJavaScriptEnabled(true); //支持js
        webSettings.setSupportZoom(true); //支持縮放
//        webSettings.setBuiltInZoomControls(true); // 放大和縮小的按鈕,容易引發異常 http://blog.csdn.net/dreamer0924/article/details/34082687

        webSettings.setAppCacheEnabled(true);
        webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    }
 
開發者ID:wp521,項目名稱:MyFire,代碼行數:14,代碼來源:NewsBrowserActivity.java

示例14: initView

import android.webkit.WebSettings; //導入方法依賴的package包/類
@Override
protected void initView() {
    mId = getIntent().getLongExtra(ActivityConstant.ID, 0L);
    setSupportActionBar(mToolbar);

    final WebSettings settings = mWeb.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setLoadWithOverviewMode(true);
    settings.setSupportZoom(true);
    handleTranstion();
}
 
開發者ID:crazysunj,項目名稱:CrazyDaily,代碼行數:12,代碼來源:ZhihuNewsDetailActivity.java

示例15: onCreate

import android.webkit.WebSettings; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    init();
    WebSettings settings = webView.getSettings();
    webView.loadUrl("https://yujiepan.github.io/fun.html");
    settings.setSupportZoom(true);          //支持縮放
    settings.setBuiltInZoomControls(true);  //啟用內置縮放裝置
    settings.setJavaScriptEnabled(true);    //啟用JS腳本


}
 
開發者ID:hgs1217,項目名稱:Paper-Melody,代碼行數:13,代碼來源:AboutActivity.java


注:本文中的android.webkit.WebSettings.setSupportZoom方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。