当前位置: 首页>>代码示例>>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;未经允许,请勿转载。