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