本文整理匯總了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());
}
示例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");//設置編碼格式
}
示例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); //支持自動加載圖片
}
示例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());
}
示例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();
}
示例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;
});
}
示例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");
}
示例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;
}
});
}
示例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");
}
示例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);
}
示例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());
}
示例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");
}
示例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);
}
示例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");
}