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


Java WebSettings.setLoadWithOverviewMode方法代碼示例

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


在下文中一共展示了WebSettings.setLoadWithOverviewMode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

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

示例2: initWebViewSettings

import android.webkit.WebSettings; //導入方法依賴的package包/類
/**
 * @param webView
 */
@SuppressLint("SetJavaScriptEnabled")
public static void initWebViewSettings(WebView webView) {
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    webSettings.setDefaultFontSize(15);
    //設置緩存
    webSettings.setDomStorageEnabled(true);
    webSettings.setDatabaseEnabled(true);

    webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    webSettings.setAppCacheEnabled(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setAppCachePath(AppConfig.WEB_CACHE_PATH);
}
 
開發者ID:z-chu,項目名稱:FriendBook,代碼行數:21,代碼來源:AppRouter.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: 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

示例5: setUpWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void setUpWebView() {
    WebSettings settings = mWebView.getSettings();
    settings.setUseWideViewPort(true);
    settings.setBuiltInZoomControls(true);
    settings.setLoadWithOverviewMode(true);
    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setDomStorageEnabled(true);
    settings.setDisplayZoomControls(false);
    mWebView.setWebViewClient(new MyWebViewClient());
    mWebView.setWebChromeClient(new MyWebChromeClient());
}
 
開發者ID:hyb1996,項目名稱:Auto.js,代碼行數:13,代碼來源:EWebView.java

示例6: 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);
}
 
開發者ID:JunGeges,項目名稱:AliZhiBoHao,代碼行數:39,代碼來源:WebActivity.java

示例7: initializeOptions

import android.webkit.WebSettings; //導入方法依賴的package包/類
@SuppressLint({"SetJavaScriptEnabled", "NewApi"})
public void initializeOptions() {
    WebSettings settings = getSettings();
    if (VERSION.SDK_INT >= 21) {
        CookieManager.getInstance().setAcceptThirdPartyCookies(this, true);
    }
    settings.setUserAgentString(OtherUtil.getUserAgent(this.mContext));
    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setCacheMode(2);
    settings.setAllowFileAccess(true);
    settings.setDefaultTextEncodingName("utf-8");
    settings.setAppCacheEnabled(true);
    settings.setGeolocationEnabled(true);
    settings.setDatabaseEnabled(true);
    settings.setDomStorageEnabled(true);
    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);
    settings.setLoadsImagesAutomatically(true);
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);
    settings.setSaveFormData(true);
    CookieManager.getInstance().setAcceptCookie(true);
    setLongClickable(false);
    setScrollbarFadingEnabled(true);
    setScrollBarStyle(0);
    setDrawingCacheEnabled(true);
    setClickable(true);
    setVerticalScrollBarEnabled(false);
    setHorizontalScrollBarEnabled(false);
    requestFocus();
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:33,代碼來源:CustomWebView.java

示例8: onCreate

import android.webkit.WebSettings; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Context of this activity
    mContext = this;

    // Get main WebView component
    mWebView = (WebView) findViewById(R.id.wv_main);

    // Get ProgressBar component
    mProgress = (ProgressBar) findViewById(R.id.pb_loading);

    // Attach clients to mWebView to measure progress and errors
    mWebView.setWebViewClient(new WebClient());
    mWebView.setWebChromeClient(new ChromeClient());

    // Get settings for mWebView
    WebSettings settings = mWebView.getSettings();
    // The two lines below are to enable interpreting <meta viewport> tag.
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);
    // Enable JavaScript
    settings.setJavaScriptEnabled(true);

    // Load AdBlocker
    mAdBlocker = new AdBlocker(this);
    mAdBlocker.execute();

    // Load MangaFox
    if (savedInstanceState != null) {
        mWebView.restoreState(savedInstanceState);
    } else {
        mWebView.loadUrl(MANGAFOX_URL);
    }
}
 
開發者ID:dipu-bd,項目名稱:mangafox,代碼行數:38,代碼來源:MainActivity.java

示例9: setWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void setWebView(@NonNull final String newsSrc) {
    if (newsWebView != null) {
        WebSettings settings = this.newsWebView.getSettings();
        settings.setUseWideViewPort(true);
        settings.setBuiltInZoomControls(true);
        settings.setLoadWithOverviewMode(true);
        this.newsWebView.loadUrl(newsSrc);
    }
}
 
開發者ID:ZafraniTechLLC,項目名稱:Companion-For-PUBG-Android,代碼行數:10,代碼來源:NewsDetailFragment.java

示例10: onCreate

import android.webkit.WebSettings; //導入方法依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_activity_show_result);
    webView = (WebView) findViewById(R.id.web_content);
    tv = (TextView) findViewById(R.id.tv);
    pb = (ProgressBar) findViewById(R.id.progress);

    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webView.setWebChromeClient(webChromeClient);
    webView.setWebViewClient(webViewClient);

    Intent intent = getIntent();
    if (intent != null) {
        resultText = intent.getStringExtra(Constant.EXTRA_RESULT_TEXT_FROM_PIC);
        if (Patterns.WEB_URL.matcher(resultText).matches()) {
            //是一個web url
            tv.setVisibility(View.GONE);
            webView.setVisibility(View.VISIBLE);
            webView.loadUrl(resultText);
        } else {
            //不是web url
            tv.setVisibility(View.VISIBLE);
            webView.setVisibility(View.GONE);
            pb.setVisibility(View.GONE);
            tv.setText(resultText);
        }
    }
}
 
開發者ID:MRYangY,項目名稱:YZxing,代碼行數:33,代碼來源:ShowResultActivity.java

示例11: settingWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
/**
 * 初始化設置
 */
public void settingWebView() {
    WebSettings settings = getSettings();
    String ua = settings.getUserAgentString();
    // 設置瀏覽器UA,JS端通過UA判斷是否屬於Quick環境
    settings.setUserAgentString(ua + " QuickHybridJs/" + BuildConfig.VERSION_NAME);
    // 設置支持JS
    settings.setJavaScriptEnabled(true);
    // 設置是否支持meta標簽來控製縮放
    settings.setUseWideViewPort(true);
    // 縮放至屏幕的大小
    settings.setLoadWithOverviewMode(true);
    // 設置內置的縮放控件(若SupportZoom為false,該設置項無效)
    settings.setBuiltInZoomControls(true);
    // 設置緩存模式
    // LOAD_DEFAULT 根據HTTP協議header中設置的cache-control屬性來執行加載策略
    // LOAD_CACHE_ELSE_NETWORK 隻要本地有無論是否過期都從本地獲取
    settings.setCacheMode(WebSettings.LOAD_DEFAULT);
    settings.setDomStorageEnabled(true);
    // 設置AppCache 需要H5頁麵配置manifest文件(官方已不推介使用)
    String appCachePath = getContext().getCacheDir().getAbsolutePath();
    settings.setAppCachePath(appCachePath);
    settings.setAppCacheEnabled(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // 強製開啟android webview debug模式使用Chrome inspect(https://developers.google.com/web/tools/chrome-devtools/remote-debugging/)
        WebView.setWebContentsDebuggingEnabled(true);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        CookieManager.getInstance().setAcceptThirdPartyCookies(this, true);
    }
}
 
開發者ID:quickhybrid,項目名稱:quickhybrid-android,代碼行數:34,代碼來源:QuickWebView.java

示例12: setDesktopMode

import android.webkit.WebSettings; //導入方法依賴的package包/類
/**
 * Force web sites to show their desktop versions
 * @param enabled false loads the mobile version
 */
public void setDesktopMode(boolean enabled) {
    WebSettings webSettings = getSettings();
    String newUserAgent;
    if (enabled)
        newUserAgent = webSettings.getUserAgentString().replace("Mobile", "eliboM").replace("Android", "diordnA");
    else
        newUserAgent = webSettings.getUserAgentString().replace("eliboM", "Mobile").replace("diordnA", "Android");
    webSettings.setUserAgentString(newUserAgent);
    webSettings.setUseWideViewPort(enabled);
    webSettings.setLoadWithOverviewMode(enabled);
    webSettings.setSupportZoom(enabled);
    webSettings.setBuiltInZoomControls(enabled);
}
 
開發者ID:vic797,項目名稱:prowebview,代碼行數:18,代碼來源:ProWebView.java

示例13: initWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void initWebView() {
    mProgressBar.setVisibility(View.VISIBLE);
    WebSettings ws = webView.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
    webView.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);

    mWebChromeClient = new MyWebChromeClient(this);
    webView.setWebChromeClient(mWebChromeClient);
    // 與js交互
    webView.addJavascriptInterface(new ImageClickInterface(this), "injectedObject");
    webView.setWebViewClient(new MyWebViewClient(this));
}
 
開發者ID:joelan,項目名稱:ClouldReader,代碼行數:45,代碼來源:WebViewActivity.java

示例14: onCreate

import android.webkit.WebSettings; //導入方法依賴的package包/類
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
    overridePendingTransition(0, 0);
    super.onCreate(savedInstanceState);
    swipeBackDelegate = new SwipeBackDelegate();
    swipeBackDelegate.attach(this, R.layout.web_activity_web);
    swipeBackDelegate.setDragEdge(DragEdge.VERTICAL);
    /* setContentView(R.layout.web_activity_web); */

    progressbar = (NumberProgressBar) findViewById(R.id.progressbar);
    webView = (ObservableWebView) findViewById(R.id.web_view);
    textSwitcher = (TextSwitcher) findViewById(R.id.title);

    url = getIntent().getStringExtra(EXTRA_URL);
    title = getIntent().getStringExtra(EXTRA_TITLE);

    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setLoadWithOverviewMode(true);
    settings.setAppCacheEnabled(true);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    settings.setSupportZoom(true);
    settings.setDomStorageEnabled(true);
    webView.setWebChromeClient(new ChromeClient());
    webView.setWebViewClient(new ReloadableClient());
    webView.setOnScrollChangedListener(this);
    // webView.addJavascriptInterface(new JSInterface(), "JSInterface");

    webView.loadUrl(url);

    textSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
        @SuppressWarnings("deprecation")
        @Override
        public View makeView() {
            final Context context = WebActivity.this;
            final TextView textView = new TextView(context);
            textView.setTextAppearance(context, R.style.WebTitle);
            textView.setSingleLine(true);
            textView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
            textView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(final View v) {
                    v.setSelected(!v.isSelected());
                }
            });
            return textView;
        }
    });
    textSwitcher.setInAnimation(this, android.R.anim.fade_in);
    textSwitcher.setOutAnimation(this, android.R.anim.fade_out);
    if (title != null) setTitle(title);
}
 
開發者ID:drakeet,項目名稱:rebase-android,代碼行數:54,代碼來源:WebActivity.java

示例15: configure

import android.webkit.WebSettings; //導入方法依賴的package包/類
/**
 * Configure a {@link WebView} to display a Message. This method takes into account a user's
 * preferences when configuring the view. This message is used to view a message and to display a message being
 * replied to.
 */
public void configure() {
    this.setVerticalScrollBarEnabled(true);
    this.setVerticalScrollbarOverlay(true);
    this.setScrollBarStyle(SCROLLBARS_INSIDE_OVERLAY);
    this.setLongClickable(true);

    if (QMail.getK9MessageViewTheme() == Theme.DARK) {
        // Black theme should get a black webview background
        // we'll set the background of the messages on load
        this.setBackgroundColor(0xff000000);
    }

    final WebSettings webSettings = this.getSettings();

    webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);

    /* TODO this might improve rendering smoothness when webview is animated into view
    if (VERSION.SDK_INT >= VERSION_CODES.M) {
        webSettings.setOffscreenPreRaster(true);
    }
    */

    webSettings.setSupportZoom(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setUseWideViewPort(true);
    if (QMail.autofitWidth()) {
        webSettings.setLoadWithOverviewMode(true);
    }

    disableDisplayZoomControls();

    webSettings.setJavaScriptEnabled(false);
    webSettings.setLoadsImagesAutomatically(true);
    webSettings.setRenderPriority(RenderPriority.HIGH);

    // TODO:  Review alternatives.  NARROW_COLUMNS is deprecated on KITKAT
    webSettings.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);

    setOverScrollMode(OVER_SCROLL_NEVER);

    webSettings.setTextZoom(QMail.getFontSizes().getMessageViewContentAsPercent());

    // Disable network images by default.  This is overridden by preferences.
    blockNetworkData(true);
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:51,代碼來源:MessageWebView.java


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