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


Java WebSettings.setLayoutAlgorithm方法代碼示例

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


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

示例4: initView

import android.webkit.WebSettings; //導入方法依賴的package包/類
@Override
public void initView() {
    webView = (WebView) getView().findViewById(R.id.webview);
    webView.loadUrl("https://github.com/youth5201314/XFrame/wiki");
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setUseWideViewPort(true);
    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    });
}
 
開發者ID:youth5201314,項目名稱:XFrame,代碼行數:21,代碼來源:APIFragment.java

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

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

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

示例8: initSettings

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void initSettings() {
	WebSettings settings = getSettings();
	settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
	settings.setUseWideViewPort(true);
	settings.setJavaScriptEnabled(true);
	setVerticalScrollBarEnabled(false);
	setHorizontalScrollBarEnabled(false);
	settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
}
 
開發者ID:MobClub,項目名稱:BBSSDK-for-Android,代碼行數:10,代碼來源:BaseWebView.java

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

示例10: initView

import android.webkit.WebSettings; //導入方法依賴的package包/類
@Override
public void initView() {
    //不知道為什麽如果webview用addview進FrameLyout會導致真機內存泄露,模擬器不管什麽方式都內存泄露,不過真機不用addview就不會。
    WebSettings settings = wvDetailContent.getSettings();
    settings.setAppCacheEnabled(true);
    settings.setDomStorageEnabled(true);
    settings.setDatabaseEnabled(true);
    settings.setCacheMode(WebSettings.LOAD_DEFAULT);
    settings.setJavaScriptEnabled(true);
    settings.setLoadWithOverviewMode(true);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    settings.setSupportZoom(true);
    wvDetailContent.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    });
    nsvZhihuDetail.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            if (scrollY - oldScrollY > 0 && isBottomShow) {  //下移隱藏
                isBottomShow = false;
                flDetailBottom.animate().translationY(flDetailBottom.getHeight());
            } else if (scrollY - oldScrollY < 0 && !isBottomShow) {    //上移出現
                isBottomShow = true;
                flDetailBottom.animate().translationY(0);
            }
        }
    });
}
 
開發者ID:paterWang,項目名稱:EasyReader,代碼行數:33,代碼來源:ZhiHuDetailActivity.java

示例11: setThemeSource

import android.webkit.WebSettings; //導入方法依賴的package包/類
public void setThemeSource(@NonNull String source, @Nullable String theme) {
    if (!InputHelper.isEmpty(source)) {
        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 = PrettifyHelper.generateContent(source, theme);
        loadCode(page);
    }
}
 
開發者ID:duyp,項目名稱:mvvm-template,代碼行數:13,代碼來源:PrettifyWebView.java

示例12: setSource

import android.webkit.WebSettings; //導入方法依賴的package包/類
public void setSource(@NonNull String source, boolean wrap) {
    if (!InputHelper.isEmpty(source)) {
        WebSettings settings = getSettings();
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
        setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        settings.setSupportZoom(!wrap);
        settings.setBuiltInZoomControls(!wrap);
        if (!wrap) settings.setDisplayZoomControls(false);
        String page = PrettifyHelper.generateContent(source, AppHelper.isNightMode(getResources()), wrap);
        loadCode(page);
    }
}
 
開發者ID:duyp,項目名稱:mvvm-template,代碼行數:13,代碼來源:PrettifyWebView.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: b

import android.webkit.WebSettings; //導入方法依賴的package包/類
private boolean b() {
    this.b = (WebView) this.d.findViewById(ResContainer.getResourceId(this.k, ResType.ID,
            "webView"));
    this.b.setWebViewClient(c());
    this.b.setWebChromeClient(new p(this));
    this.b.requestFocusFromTouch();
    this.b.setVerticalScrollBarEnabled(false);
    this.b.setHorizontalScrollBarEnabled(false);
    this.b.setScrollBarStyle(0);
    this.b.getSettings().setCacheMode(2);
    WebSettings settings = this.b.getSettings();
    settings.setJavaScriptEnabled(true);
    if (VERSION.SDK_INT >= 8) {
        settings.setPluginState(PluginState.ON);
    }
    settings.setSupportZoom(true);
    settings.setBuiltInZoomControls(true);
    settings.setAllowFileAccess(true);
    settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
    settings.setUseWideViewPort(true);
    if (VERSION.SDK_INT >= 8) {
        settings.setLoadWithOverviewMode(true);
        settings.setDatabaseEnabled(true);
        settings.setDomStorageEnabled(true);
        settings.setGeolocationEnabled(true);
        settings.setAppCacheEnabled(true);
    }
    if (VERSION.SDK_INT >= 11) {
        try {
            Method declaredMethod = WebSettings.class.getDeclaredMethod
                    ("setDisplayZoomControls", new Class[]{Boolean.TYPE});
            declaredMethod.setAccessible(true);
            declaredMethod.invoke(settings, new Object[]{Boolean.valueOf(false)});
        } catch (Exception e) {
        }
    }
    try {
        if (this.m == SHARE_MEDIA.RENREN) {
            CookieSyncManager.createInstance(this.k);
            CookieManager.getInstance().removeAllCookie();
        }
    } catch (Exception e2) {
    }
    return true;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:46,代碼來源:j.java


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