本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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;
}
});
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
});
}
示例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);
}
}
示例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);
}
}
示例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));
}
示例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);
}
示例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;
}