当前位置: 首页>>代码示例>>Java>>正文


Java WebSettings.setLoadsImagesAutomatically方法代码示例

本文整理汇总了Java中android.webkit.WebSettings.setLoadsImagesAutomatically方法的典型用法代码示例。如果您正苦于以下问题:Java WebSettings.setLoadsImagesAutomatically方法的具体用法?Java WebSettings.setLoadsImagesAutomatically怎么用?Java WebSettings.setLoadsImagesAutomatically使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.webkit.WebSettings的用法示例。


在下文中一共展示了WebSettings.setLoadsImagesAutomatically方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initWidgets

import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
protected void initWidgets() {
    super.initWidgets();
    mBackImg = (ImageView) findViewById(R.id.kf5_return_img);
    mBackImg.setOnClickListener(this);
    mWebView = (WebView) findViewById(R.id.kf5_post_detail_content);
    mDetailTitle = (TextView) findViewById(R.id.kf5_post_detail_title);
    mDate = (TextView) findViewById(R.id.kf5_post_detail_date);
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setBuiltInZoomControls(false);
    webSettings.setDomStorageEnabled(true);
    webSettings.setDatabaseEnabled(true);
    webSettings.setAppCacheEnabled(true);
    webSettings.setLoadsImagesAutomatically(true);
    webSettings.setPluginState(WebSettings.PluginState.ON);
    webSettings.setBuiltInZoomControls(false); //显示放大缩小 controler
    webSettings.setSupportZoom(false); //可以缩放
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    mWebView.setWebViewClient(new MyWebViewClient());
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:21,代码来源:HelpCenterTypeDetailsActivity.java

示例2: initWebView

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebView() {
        WebSettings webSettings = webView.getSettings();
//        webSettings.setJavaScriptEnabled(true);

        webSettings.setUseWideViewPort(true); //将图片调整到适合webview的大小
        webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕的大小

        webSettings.setSupportZoom(true); //支持缩放,默认为true。是下面那个的前提。
        webSettings.setBuiltInZoomControls(true); //设置内置的缩放控件。若为false,则该WebView不可缩放
        webSettings.setDisplayZoomControls(false); //隐藏原生的缩放控件

        webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //关闭webview中缓存
        webSettings.setAllowFileAccess(true); //设置可以访问文件
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口
        webSettings.setLoadsImagesAutomatically(true); //支持自动加载图片
        webSettings.setDefaultTextEncodingName("utf-8");//设置编码格式

    }
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:19,代码来源:WebActivity.java

示例3: setWebView

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void setWebView() {
        WebSettings ws = wvNewContent.getSettings();
        ws.setJavaScriptEnabled(true);  //支持js
        ws.setPluginState(WebSettings.PluginState.ON);//设置是否支持插件
        ws.setUseWideViewPort(false);  //将图片调整到适合webview的大小
        ws.setSupportZoom(true);  //支持缩放
        ws.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); //支持内容重新布局
        ws.supportMultipleWindows();  //多窗口
        ws.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);  //关闭webview中缓存
//        cache模式有如下几种:
//        LOAD_DEFAULT: 如果我们应用程序没有设置任何cachemode, 这个是默认的cache方式。 加载一张网页会检查是否有cache,如果有并且没有过期则使用本地cache,否则从网络上获取。
//        LOAD_CACHE_ELSE_NETWORK: 使用cache资源,即使过期了也使用,如果没有cache才从网络上获取。
//        LOAD_NO_CACHE: 不使用cache 全部从网络上获取
//        LOAD_CACHE_ONLY:  只使用cache上的内容
        ws.setAllowFileAccess(true);  //设置可以访问文件
        ws.setNeedInitialFocus(true); //当webview调用requestFocus时为webview设置节点
        ws.setBuiltInZoomControls(true); //设置支持缩放
        ws.setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口
        ws.setLoadWithOverviewMode(true); // 缩放至屏幕的大小
        ws.setLoadsImagesAutomatically(true);  //支持自动加载图片
    }
 
开发者ID:guxiaonian,项目名称:MeiLa_GNN,代码行数:22,代码来源:GlobalWebViewActivity.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: 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

示例6: initView

import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled") private void initView(@Nullable AttributeSet attrs) {
    if (isInEditMode()) return;
    if (attrs != null) {
        TypedArray tp = getContext().obtainStyledAttributes(attrs, R.styleable.PrettifyWebView);
        try {
            int color = tp.getColor(R.styleable.PrettifyWebView_webview_background, ViewHelper.getWindowBackground(getContext()));
            setBackgroundColor(color);
        } finally {
            tp.recycle();
        }
    }
    setWebChromeClient(new ChromeClient());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        setWebViewClient(new WebClient());
    } else {
        setWebViewClient(new WebClientCompat());
    }
    WebSettings settings = getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setAppCachePath(getContext().getCacheDir().getPath());
    settings.setAppCacheEnabled(true);
    settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    settings.setDefaultTextEncodingName("utf-8");
    settings.setLoadsImagesAutomatically(true);
    settings.setBlockNetworkImage(false);
    setOnLongClickListener((view) -> {
        WebView.HitTestResult result = getHitTestResult();
        if (hitLinkResult(result) && !InputHelper.isEmpty(result.getExtra())) {
            AppHelper.copyToClipboard(getContext(), result.getExtra());
            return true;
        }
        return false;
    });
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:35,代码来源:PrettifyWebView.java

示例7: onCreate

import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    listeners = new ArrayList<>();
    progressListeners = new ArrayList<>();
    webView = new WebView(this);
    webView.setWebViewClient(new WebClient(this));
    webView.setWebChromeClient(new ChromeClient(this));
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setLoadsImagesAutomatically(false);
    webSettings.setUserAgentString("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0");
}
 
开发者ID:TheAndroidMaster,项目名称:Blackboard,代码行数:15,代码来源:Blackboard.java

示例8: init

import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void init(AttributeSet attrs) {
    if (attrs != null) {
        TypedArray tp = getContext().obtainStyledAttributes(attrs, R.styleable.CodeWebView);
        try {
            backgroundColor = tp.getColor(R.styleable.CodeWebView_webview_background,
                    ViewUtils.getWindowBackground(getContext()));
            setBackgroundColor(backgroundColor);
        } finally {
            tp.recycle();
        }
    }

    setWebChromeClient(new ChromeClient());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        setWebViewClient(new WebClientN());
    } else {
        setWebViewClient(new WebClient());
    }
    WebSettings settings = getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setAppCachePath(getContext().getCacheDir().getPath());
    settings.setAppCacheEnabled(true);
    settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    settings.setDefaultTextEncodingName("utf-8");
    settings.setLoadsImagesAutomatically(true);
    settings.setBlockNetworkImage(false);
    setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            WebView.HitTestResult result = getHitTestResult();
            if (hitLinkResult(result) && !StringUtils.isBlank(result.getExtra())) {
                AppUtils.copyToClipboard(getContext(), result.getExtra());
                return true;
            }
            return false;
        }
    });
}
 
开发者ID:ThirtyDegreesRay,项目名称:OpenHub,代码行数:40,代码来源:CodeWebView.java

示例9: initWebSettings

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebSettings() {
  WebSettings settings = mWebView.getSettings();
  //支持获取手势焦点
  mWebView.requestFocusFromTouch();
  //支持JS
  settings.setJavaScriptEnabled(true);
  //支持插件
  settings.setPluginState(WebSettings.PluginState.ON);
  //设置适应屏幕
  settings.setUseWideViewPort(true);
  settings.setLoadWithOverviewMode(true);
  //支持缩放
  settings.setSupportZoom(false);
  //隐藏原生的缩放控件
  settings.setDisplayZoomControls(false);
  //支持内容重新布局
  settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
  settings.supportMultipleWindows();
  settings.setSupportMultipleWindows(true);
  //设置缓存模式
  settings.setDomStorageEnabled(true);
  settings.setDatabaseEnabled(true);
  settings.setCacheMode(WebSettings.LOAD_DEFAULT);
  settings.setAppCacheEnabled(true);
  settings.setAppCachePath(mWebView.getContext().getCacheDir().getAbsolutePath());

  //设置可访问文件
  settings.setAllowFileAccess(true);
  //当webview调用requestFocus时为webview设置节点
  settings.setNeedInitialFocus(true);
  //支持自动加载图片
  if (Build.VERSION.SDK_INT >= 19) {
    settings.setLoadsImagesAutomatically(true);
  } else {
    settings.setLoadsImagesAutomatically(false);
  }
  settings.setNeedInitialFocus(true);
  //设置编码格式
  settings.setDefaultTextEncodingName("UTF-8");
}
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:41,代码来源:WebViewUI.java

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

示例11: init

import android.webkit.WebSettings; //导入方法依赖的package包/类
private void init(Context context) {
    mPlayer = new WebPlayer(this);

    setBackgroundColor(Color.BLACK);

    enableJavascript();

    WebSettings webSettings = getSettings();
    webSettings.setAllowContentAccess(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setLoadsImagesAutomatically(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setAppCacheEnabled(true);
    webSettings.setDatabaseEnabled(true);
    webSettings.setDatabasePath(context.getDir("database", Context.MODE_PRIVATE).getPath());

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        webSettings.setAllowFileAccessFromFileURLs(true);
        webSettings.setAllowUniversalAccessFromFileURLs(true);
    }
    
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
        webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
    }

    setWebChromeClient(new ChromeClient());
    setWebViewClient(new ViewClient());
}
 
开发者ID:AltimitSystems,项目名称:mv-android-client,代码行数:29,代码来源:WebPlayerView.java

示例12: initWebView

import android.webkit.WebSettings; //导入方法依赖的package包/类
public void initWebView(WebView webView) {
        webView.setVerticalScrollBarEnabled(false);
        webView.setBackgroundColor(getResources().getColor(R.color.white));
        //设置webview的配置
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
                | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

        WebSettings webseting = webView.getSettings();
        // 支持JavaScript
        webseting.setJavaScriptEnabled(true);
        // 支持保存数据
        webseting.setSaveFormData(false);
        webseting.setDomStorageEnabled(true);
//		webseting.setAppCacheMaxSize(1024 * 1024 * 8);// 设置缓冲大小,我设的是8M
        String appCacheDir = getApplicationContext().getDir("cache", Context.MODE_PRIVATE).getPath();
        webseting.setAppCachePath(appCacheDir);
        webseting.setUserAgentString(Config.FORMAT_USER_AGENT);
        webseting.setLoadWithOverviewMode(true);
        webseting.setUseWideViewPort(true);
        webseting.setDatabaseEnabled(true);
        webseting.setAllowFileAccess(true);
        webseting.setCacheMode(WebSettings.LOAD_DEFAULT);
        /*强制webview使用标准字号大小*/
        webseting.setTextZoom(100);

        // webseting.setBlockNetworkImage(true);
        webseting.setLoadsImagesAutomatically(true);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            webView.setWebContentsDebuggingEnabled(true);// Enables debugging of web contents (HTML / CSS / JavaScript) loaded into any WebViews of this application.
        }

        //移除webkit内部存在安全漏洞的javascript接口
        webView.removeJavascriptInterface("searchBoxJavaBridge_");
        webView.removeJavascriptInterface("accessibility");
        webView.removeJavascriptInterface("accessibilityTraversal");

    }
 
开发者ID:AlpacaNotSheep,项目名称:hybrid,代码行数:38,代码来源:BaseWebActivity.java

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

示例14: setWebView

import android.webkit.WebSettings; //导入方法依赖的package包/类
/**
 * 配置webView
 */
void setWebView() {
    //声明WebSettings子类
    WebSettings webSettings = mWebView.getSettings();

    //支持Javascript交互
    webSettings.setJavaScriptEnabled(true);


    //设置自适应屏幕,两者合用
    webSettings.setUseWideViewPort(true); //将图片调整到适合webview的大小
    webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕的大小

    //缩放操作
    webSettings.setSupportZoom(true); //支持缩放,默认为true。是下面那个的前提。
    webSettings.setBuiltInZoomControls(true); //设置内置的缩放控件。若为false,则该WebView不可缩放
    webSettings.setDisplayZoomControls(false); //隐藏原生的缩放控件

    //其他细节操作
    //webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //关闭webview中缓存
    webSettings.setAllowFileAccess(true); //设置可以访问文件

    //对于不需要使用 file 协议的应用,禁用 file 协议;防止文件泄密,file协议即是file://
    //webSettings.setAllowFileAccess(false);
    //webSettings.setAllowFileAccessFromFileURLs(false);
    //webSettings.setAllowUniversalAccessFromFileURLs(false);



    webSettings.setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口
    webSettings.setLoadsImagesAutomatically(true); //支持自动加载图片
    webSettings.setDefaultTextEncodingName("utf-8");//设置编码格式

    mWebView.setDownloadListener(new DownloadListener() {
        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            //网页中触发下载动作
        }
    });

    //增加js交互接口
    mWebView.addJavascriptInterface(new JsCallAndroidInterface(), "JSCallBackInterface");
}
 
开发者ID:CarGuo,项目名称:CustomActionWebView,代码行数:46,代码来源:APIWebViewActivity.java


注:本文中的android.webkit.WebSettings.setLoadsImagesAutomatically方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。