本文整理汇总了Java中android.webkit.WebSettings.ZoomDensity类的典型用法代码示例。如果您正苦于以下问题:Java ZoomDensity类的具体用法?Java ZoomDensity怎么用?Java ZoomDensity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ZoomDensity类属于android.webkit.WebSettings包,在下文中一共展示了ZoomDensity类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initSettings
import android.webkit.WebSettings.ZoomDensity; //导入依赖的package包/类
private void initSettings() {
// 初始化设置
WebSettings mSettings = this.getSettings();
mSettings.setJavaScriptEnabled(true);//开启javascript
mSettings.setDomStorageEnabled(true);//开启DOM
mSettings.setDisplayZoomControls(false);//关闭页面的放大缩小按钮
mSettings.setDefaultTextEncodingName("utf-8");//设置字符编码
//设置web页面
mSettings.setAllowFileAccess(true);//设置支持文件流
mSettings.setSupportZoom(true);// 支持缩放
mSettings.setBuiltInZoomControls(true);// 支持缩放
mSettings.setUseWideViewPort(true);// 调整到适合webview大小
mSettings.setLoadWithOverviewMode(true);// 调整到适合webview大小
mSettings.setDefaultZoom(ZoomDensity.FAR);// 屏幕自适应网页,如果没有这个,在低分辨率的手机上显示可能会异常
mSettings.setRenderPriority(RenderPriority.HIGH);
//提高网页加载速度,暂时阻塞图片加载,然后网页加载好了,在进行加载图片
mSettings.setBlockNetworkImage(true);
mSettings.setAppCacheEnabled(true);//开启缓存机制
setWebViewClient(new MyWebViewClient());
setOnLongClickListener(this);
}
开发者ID:amao12580,项目名称:BookmarkHelper,代码行数:22,代码来源:CustomWebView.java
示例2: setDefaultZoom
import android.webkit.WebSettings.ZoomDensity; //导入依赖的package包/类
public static void setDefaultZoom(WebSettings settings, ZoomDensityCompat zoom) {
switch (zoom) {
case FAR: {
settings.setDefaultZoom(ZoomDensity.FAR);
break;
}
case MEDIUM: {
settings.setDefaultZoom(ZoomDensity.MEDIUM);
break;
}
case CLOSE: {
settings.setDefaultZoom(ZoomDensity.CLOSE);
break;
}
default: {
break;
}
}
}
开发者ID:v7lin,项目名称:Android_Skin_3.x,代码行数:20,代码来源:WebSettingsCompatEclairMr1.java
示例3: loadUrlAdaptiveScreen
import android.webkit.WebSettings.ZoomDensity; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@SuppressLint("SetJavaScriptEnabled")
public static void loadUrlAdaptiveScreen(Context mContext, WebView webview,
String url, boolean javaScriptEnabled) {
WebSettings webSettings = webview.getSettings();
webSettings.setJavaScriptEnabled(javaScriptEnabled);
// 自适应屏幕
// 第一种:
// WebSetting settings = webView.getSettings();
// settings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
// 把所有内容放在webview等宽的一列中。(可能会出现页面中链接失效)
// 第二种:
// settings.setUseWideViewPort(true);
// settings.setLoadWithOverviewMode(true);
// 第三种:
DisplayMetrics metrics = new DisplayMetrics();
((Activity) mContext).getWindowManager().getDefaultDisplay()
.getMetrics(metrics);
int mDensity = metrics.densityDpi;
if (mDensity <= 120) {
webSettings.setDefaultZoom(ZoomDensity.CLOSE);
} else if (mDensity > 120 && mDensity < 240) {
webSettings.setDefaultZoom(ZoomDensity.MEDIUM);
} else if (mDensity >= 240) {
webSettings.setDefaultZoom(ZoomDensity.FAR);
}
webview.setWebViewClient(new WebViewClient());
webview.loadUrl(url);
}
开发者ID:BigAppOS,项目名称:BigApp_Discuz_Android,代码行数:32,代码来源:WebViewUtils.java
示例4: initSet
import android.webkit.WebSettings.ZoomDensity; //导入依赖的package包/类
private void initSet()
{
/**
* WebView的设置选项太多了,所以都抽取到 WebSettings中,并且谷歌
* 给了默认的设置,当创建WebView时,就会自动创建 WebSettings对象
*
* 如果想要对WebView进行设置,就需要使用这个类
*
* 获取WebSettings对象:webView.getSettings();
*/
webSet = webView.getSettings();
webSet.setSupportZoom(true);//是否支持缩放
webSet.setDefaultZoom(ZoomDensity.MEDIUM);//设置默认的缩放级别
webSet.setJavaScriptEnabled(true);//是否支持javaScript
webSet.setTextSize(TextSize.SMALLER); // 设置文字的大小
// webSet.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);//设置布局样式
// webSet.setBuiltInZoomControls(true);//打开自带的缩放按钮
webView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
System.out.println("onTouch==========");
return false;
}
});// TestBug
webView.setWebViewClient(webViewClient);
webView.setWebChromeClient(webChromeClient);
webView.addJavascriptInterface(new Object(){
public void callFromJS(String msg){
showToast(msg);
}
}, "heima");
}
开发者ID:cowthan,项目名称:AyoSunny,代码行数:41,代码来源:MyWebViewActivity.java
示例5: onCreate
import android.webkit.WebSettings.ZoomDensity; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.about);
current_content_title = (TextView) this
.findViewById(R.id.current_content_title);
current_content_title.setText(R.string.sys_about_us);
current_content_title_back = (TextView) this
.findViewById(R.id.current_content_title_back);
current_content_title_back.setOnClickListener(this);
about_us = (WebView) this.findViewById(R.id.about_us);
WebSettings mWebSettings = about_us.getSettings();
mWebSettings.setBuiltInZoomControls(true); // 支持页面放大缩小按钮
mWebSettings.setSupportZoom(true);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
mDensity = metrics.densityDpi;
if (mDensity == 240) { // 可以让不同的density的情况下,可以让页面进行适配
mWebSettings.setDefaultZoom(ZoomDensity.FAR);
} else if (mDensity == 160) {
mWebSettings.setDefaultZoom(ZoomDensity.MEDIUM);
} else if (mDensity == 120) {
mWebSettings.setDefaultZoom(ZoomDensity.CLOSE);
}
}
开发者ID:samuelhehe,项目名称:AppMarket,代码行数:30,代码来源:AtyAbout.java
示例6: initView
import android.webkit.WebSettings.ZoomDensity; //导入依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void initView()
{
Intent intent = getIntent();
String url = intent.getStringExtra(URL);
webView = (WebView) findViewById(R.id.webView);
webView.clearHistory();
webView.loadUrl(url);
webView.setWebViewClient(new BrowserClient());
webView.setInitialScale(0);
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(false);
settings.setPluginState(PluginState.ON);
settings.setLoadWithOverviewMode(true);
settings.setSupportMultipleWindows(false);
settings.setDefaultZoom(ZoomDensity.FAR);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
settings.setUseWideViewPort(true);
settings.setDomStorageEnabled(true);
Button btnDone = (Button) findViewById(R.id.btnDone);
btnDone.setOnClickListener(this);
imgBack = (ImageView) findViewById(R.id.imgBack);
imgForward = (ImageView) findViewById(R.id.imgForward);
imgBack.setOnClickListener(this);
imgForward.setOnClickListener(this);
checkButtonState();
}
开发者ID:fblandroidhackathon,项目名称:persontracker,代码行数:38,代码来源:BrowserActivity.java
示例7: showBrowserView
import android.webkit.WebSettings.ZoomDensity; //导入依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void showBrowserView()
{
switchToLayout(R.layout.browse_web_screen);
WebView webView = (WebView) findViewById(R.id.webView);
// webView.setWebViewClient(new BrowserClient());
actionBar.setWebView(webView);
if (webViewClient == null) {
webViewClient = new ParrotWebViewClient();
}
if (webChromeClient == null) {
webChromeClient = new ParrotWebChromeClient();
}
webView.setWebViewClient(webViewClient);
webView.setWebChromeClient(webChromeClient);
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(false);
settings.setPluginState(PluginState.ON);
settings.setLoadWithOverviewMode(true);
settings.setSupportMultipleWindows(false);
settings.setDefaultZoom(ZoomDensity.FAR);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
settings.setUseWideViewPort(true);
webView.setInitialScale(0);
}
开发者ID:fblandroidhackathon,项目名称:persontracker,代码行数:33,代码来源:GuestSpaceActivity.java
示例8: init
import android.webkit.WebSettings.ZoomDensity; //导入依赖的package包/类
private void init() {
this.setBackgroundColor(Color.TRANSPARENT); // Background color
this.setInitialScale(1); // Make whole image viewable.
this.getSettings().setUseWideViewPort(true);
this.getSettings().setDefaultZoom(ZoomDensity.FAR);
this.getSettings().setLoadWithOverviewMode(true);
}
开发者ID:justinmwarner,项目名称:GestureTutorial,代码行数:9,代码来源:TutorialView.java
示例9: init
import android.webkit.WebSettings.ZoomDensity; //导入依赖的package包/类
private void init(Context context) {
mContext = context;
mLayout = new FrameLayout(context);
mBrowserFrameLayout = (FrameLayout) LayoutInflater.from(context)
.inflate(R.layout.common_custom_screen, null);
wv_imgbtn_back = (LinearLayout) mBrowserFrameLayout.findViewById(R.id.top_bar_linear_back);
wv_tv_title = (TextView) mBrowserFrameLayout.findViewById(R.id.top_bar_title);
mContentView = (FrameLayout) mBrowserFrameLayout
.findViewById(R.id.main_content);
mCustomViewContainer = (FrameLayout) mBrowserFrameLayout
.findViewById(R.id.fullscreen_custom_content);
frame_progress = (FrameLayout) mBrowserFrameLayout
.findViewById(R.id.frame_progress);
webview_tv_progress = (TextView) frame_progress
.findViewById(R.id.webview_tv_progress);
final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER);
mLayout.addView(mBrowserFrameLayout, COVER_SCREEN_PARAMS);
mWebChromeClient = new MyWebChromeClient();
setWebChromeClient(mWebChromeClient);
setWebViewClient(new MyWebViewClient());
WebSettings webSettings = this.getSettings();
webSettings.setJavaScriptEnabled(true); //开启javascript
webSettings.setDomStorageEnabled(true); //开启DOM
webSettings.setDefaultTextEncodingName("utf-8"); //设置编码
// // web页面处理
webSettings.setAllowFileAccess(true);// 支持文件流
// webSettings.setSupportZoom(true);// 支持缩放
// webSettings.setBuiltInZoomControls(true);// 支持缩放
webSettings.setUseWideViewPort(true);// 调整到适合webview大小
webSettings.setLoadWithOverviewMode(true);// 调整到适合webview大小
webSettings.setDefaultZoom(ZoomDensity.FAR);// 屏幕自适应网页,如果没有这个,在低分辨率的手机上显示可能会异常
webSettings.setRenderPriority(RenderPriority.HIGH);
//提高网页加载速度,暂时阻塞图片加载,然后网页加载好了,在进行加载图片
webSettings.setBlockNetworkImage(true);
//开启缓存机制
webSettings.setAppCacheEnabled(true);
//根据当前网页连接状态
if(StrUtils.getAPNType(context)== StrUtils.WIFI){
//设置无缓存
webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
}else{
//设置缓存
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
}
mContentView.addView(this);
// 返回
wv_imgbtn_back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
closeAdWebPage();
}
});
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:56,代码来源:HTML5CustomWebView.java
示例10: onCreate
import android.webkit.WebSettings.ZoomDensity; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.about);
this.recBean = (RecommandBean) getIntent().getSerializableExtra(
RecommandBean.TAG.RecommandBean);
current_content_title = (TextView) this
.findViewById(R.id.current_content_title);
current_content_title.setText("应用推广");
current_content_title_back = (TextView) this
.findViewById(R.id.current_content_title_back);
current_content_title_back.setOnClickListener(this);
about_us = (WebView) this.findViewById(R.id.about_us);
WebSettings mWebSettings = about_us.getSettings();
about_us.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
mWebSettings.setBuiltInZoomControls(true); // 支持页面放大缩小按钮
mWebSettings.setSupportZoom(true);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
mDensity = metrics.densityDpi;
if (mDensity == 240) { // 可以让不同的density的情况下,可以让页面进行适配
mWebSettings.setDefaultZoom(ZoomDensity.FAR);
} else if (mDensity == 160) {
mWebSettings.setDefaultZoom(ZoomDensity.MEDIUM);
} else if (mDensity == 120) {
mWebSettings.setDefaultZoom(ZoomDensity.CLOSE);
}
}
开发者ID:samuelhehe,项目名称:AppMarket,代码行数:42,代码来源:AtyAd.java
示例11: initializeOptions
import android.webkit.WebSettings.ZoomDensity; //导入依赖的package包/类
/**
* Initialize the WebView with the options set by the user through preferences.
*/
public void initializeOptions() {
WebSettings settings = getSettings();
// User settings
settings.setJavaScriptEnabled(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_JAVASCRIPT, true));
settings.setLoadsImagesAutomatically(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_IMAGES, true));
settings.setUseWideViewPort(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_USE_WIDE_VIEWPORT, true));
settings.setLoadWithOverviewMode(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_LOAD_WITH_OVERVIEW, false));
settings.setSaveFormData(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_FORM_DATA, true));
settings.setSavePassword(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_PASSWORDS, true));
settings.setDefaultZoom(ZoomDensity.valueOf(Controller.getInstance().getPreferences().getString(Constants.PREFERENCES_DEFAULT_ZOOM_LEVEL, ZoomDensity.MEDIUM.toString())));
settings.setUserAgentString(Controller.getInstance().getPreferences().getString(Constants.PREFERENCES_BROWSER_USER_AGENT, Constants.USER_AGENT_DEFAULT));
CookieManager.getInstance().setAcceptCookie(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_COOKIES, true));
if (Build.VERSION.SDK_INT <= 7) {
settings.setPluginsEnabled(Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_PLUGINS_ECLAIR, true));
} else {
settings.setPluginState(PluginState.valueOf(Controller.getInstance().getPreferences().getString(Constants.PREFERENCES_BROWSER_ENABLE_PLUGINS, PluginState.ON_DEMAND.toString())));
}
settings.setSupportZoom(true);
if (Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_BROWSER_ENABLE_PROXY_SETTINGS, false)) {
ProxySettings.setSystemProxy(mContext);
} else {
ProxySettings.resetSystemProxy(mContext);
}
// Technical settings
settings.setSupportMultipleWindows(true);
setLongClickable(true);
setScrollbarFadingEnabled(true);
setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
setDrawingCacheEnabled(true);
settings.setAppCacheEnabled(true);
settings.setDatabaseEnabled(true);
settings.setDomStorageEnabled(true);
}
开发者ID:mashiwoo,项目名称:zirco-browser,代码行数:44,代码来源:CustomWebView.java
示例12: init
import android.webkit.WebSettings.ZoomDensity; //导入依赖的package包/类
@SuppressLint({
"SetJavaScriptEnabled", "NewApi"
})
private void init(Context context, AttributeSet attrs, int defStyle) {
if (context == null) {
return;
}
// enable JavaScript
WebSettings settings = this.getSettings();
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
settings.setLoadWithOverviewMode(true);
settings.setDefaultZoom(ZoomDensity.FAR);
//settings.setUseWideViewPort(true);
//webView.setInitialScale(1);
// init attrs
TypedArray a = getContext().obtainStyledAttributes(attrs,
R.styleable.CustomWebView);
try {
int type = a.getInteger(R.styleable.CustomWebView_type, 0);
switch (type) {
case 0:
script = context.getString(R.string.html_notfound);
break;
case 1:
script = context.getString(R.string.html_qq_narrow);
break;
case 2:
script = context.getString(R.string.html_qq_narrow);
break;
case 3:
script = context.getString(R.string.html_qq_wide);
break;
case 4:
script = context.getString(R.string.html_yibo);
break;
default:
script = a.getString(R.styleable.CustomWebView_script);
break;
}
} finally {
a.recycle();
}
}
开发者ID:snowdream,项目名称:notfound-webview,代码行数:51,代码来源:NotFoundWebView.java
示例13: setDefaultZoom
import android.webkit.WebSettings.ZoomDensity; //导入依赖的package包/类
/**
* Sets the default zoom density of the page. This must be called from the UI
* thread. The default is {@link ZoomDensity#MEDIUM}.
*
* @param zoom the zoom density
*/
public abstract void setDefaultZoom(ZoomDensity zoom);
开发者ID:R4md4c,项目名称:cordova-android-chromium,代码行数:8,代码来源:ChromiumSettings.java
示例14: getDefaultZoom
import android.webkit.WebSettings.ZoomDensity; //导入依赖的package包/类
/**
* Gets the default zoom density of the page. This should be called from
* the UI thread.
*
* @return the zoom density
* @see #setDefaultZoom
*/
public abstract ZoomDensity getDefaultZoom();
开发者ID:R4md4c,项目名称:cordova-android-chromium,代码行数:9,代码来源:ChromiumSettings.java
注:本文中的android.webkit.WebSettings.ZoomDensity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论