本文整理汇总了Java中android.webkit.WebSettings.setDefaultFontSize方法的典型用法代码示例。如果您正苦于以下问题:Java WebSettings.setDefaultFontSize方法的具体用法?Java WebSettings.setDefaultFontSize怎么用?Java WebSettings.setDefaultFontSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.webkit.WebSettings
的用法示例。
在下文中一共展示了WebSettings.setDefaultFontSize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint({"AddJavascriptInterface", "SetJavaScriptEnabled"})
private void init() {
setClickable(false);
setFocusable(false);
setHorizontalScrollBarEnabled(false);
WebSettings settings = getSettings();
settings.setDefaultFontSize(14);
settings.setSupportZoom(false);
settings.setBuiltInZoomControls(false);
settings.setDisplayZoomControls(false);
settings.setJavaScriptEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
addJavascriptInterface(new OnWebViewImageListener() {
@Override
@JavascriptInterface
public void showImagePreview(String bigImageUrl) {
if (bigImageUrl != null && !StringUtils.isEmpty(bigImageUrl)) {
ImageGalleryActivity.show(getContext(), bigImageUrl);
}
}
}, "mWebViewImageListener");
}
}
示例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: setTextSize
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void setTextSize() {
WebSettings webSettings = mHelpView.getSettings();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
int textSize = SettingsActivity.getNumericPref(prefs, SettingsActivity.KEY_TEXT_SIZE, SettingsActivity.DEF_TEXT_SIZE);
if (textSize >= 16) {
webSettings.setDefaultFontSize(16 + FONT_OFFSET);
} else if (textSize >= 14) {
webSettings.setDefaultFontSize(14 + FONT_OFFSET);
} else if (textSize >= 12) {
webSettings.setDefaultFontSize(12 + FONT_OFFSET);
} else if (textSize >= 10) {
webSettings.setDefaultFontSize(10 + FONT_OFFSET);
} else if (textSize >= 8) {
webSettings.setDefaultFontSize(8 + FONT_OFFSET);
} else {
webSettings.setDefaultFontSize(16);
}
}
示例4: initWebView
import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint({"JavascriptInterface", "SetJavaScriptEnabled"})
public static void initWebView(WebView webView) {
WebSettings settings = webView.getSettings();
settings.setDefaultFontSize(14);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(false);
settings.setBuiltInZoomControls(false);
int sysVersion = Build.VERSION.SDK_INT;
if (sysVersion >= 11) {
settings.setDisplayZoomControls(false);
} else {
ZoomButtonsController zbc = new ZoomButtonsController(webView);
zbc.getZoomControls().setVisibility(View.GONE);
}
//webView.setWebViewClient(UiUtil.getWebViewClient());
}
示例5: initWebViewSettings
import android.webkit.WebSettings; //导入方法依赖的package包/类
public static void initWebViewSettings(WebView webView) {
WebSettings settings = webView.getSettings();
//这个单位是SP
settings.setDefaultFontSize(15);
settings.setJavaScriptEnabled(true); //支持js
settings.setUseWideViewPort(false); //将图片调整到适合webview的大小
settings.setSupportZoom(true); //支持缩放
settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);//无论是否有网络,只要本地有缓存,都使用缓存。本地没有缓存时才从网络上获取。 这里的WebView主要是用来加载图片和解析Html文本
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); //支持内容重新布局
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//使超链接失效
return true;
}
});
}
示例6: initData
import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void initData() {
super.initData();
WebSettings settings = mWebView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setDefaultFontSize(10);
settings.setAllowContentAccess(true);
mWebView.setWebChromeClient(new WebChromeClient() {
});
mEditor = new SourceEditor(mWebView);
mTextFileName.setText(getArguments().getString("fileName"));
mPresenter.getCodeDetail();
}
示例7: onCreate
import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
Intent in = getIntent();
web = in.getStringExtra("web");
if (TextUtils.isEmpty(web)) {
Toast.makeText(this, "地址为空", Toast.LENGTH_SHORT).show();
} else {
WebView webView = (WebView) findViewById(R.id.web);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;// 返回false
}
});
WebSettings webSettings = webView.getSettings();
// 让WebView能够执行javaScript
webSettings.setJavaScriptEnabled(true);
// 让JavaScript可以自动打开windows
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
// // 设置缓存
// webSettings.setAppCacheEnabled(true);
// // 设置缓存模式,一共有四种模式
// webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
// // 设置缓存路径
// webSettings.setAppCachePath("/storage/emulated/0/Android/data/com.easyar.buddha/files");
// 支持缩放(适配到当前屏幕)
webSettings.setSupportZoom(true);
// 将图片调整到合适的大小
webSettings.setUseWideViewPort(true);
// 支持内容重新布局,一共有四种方式
// 默认的是NARROW_COLUMNS
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
// 设置可以被显示的屏幕控制
webSettings.setDisplayZoomControls(true);
// 设置默认字体大小
webSettings.setDefaultFontSize(12);
webView.loadUrl(web);
}
}
示例8: onCreateView
import android.webkit.WebSettings; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_coding, container, false);
TextView title = (TextView)v.findViewById(R.id.codeheading);
title.setText(getArguments().getString("title"));
//Toolbar toolbar = (Toolbar)getActivity().findViewById(R.id.toolbarcoding);
WebView webView = (WebView)v.findViewById(R.id.webview);
//webView.setWebChromeClient(new MyWebViewClient());
//progress.setMax(100);
WebSettings webSettings = webView.getSettings();
webView.setWebViewClient(new WebViewClient());
webSettings.setDefaultFontSize(25);
webView.getSettings().setJavaScriptEnabled(true);
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webView.getSettings().setBuiltInZoomControls(true);
//webSettings.getSettings().setLoadsImagesAutomatically(true);
if(isNetworkAvailable()) {
Toast.makeText(getActivity(),"Loading Data....",Toast.LENGTH_SHORT).show();
String url = getArguments().getString("url");
//codingFragment.this.progress.setProgress(0);
webView.loadDataWithBaseURL("", url, "text/html", "UTF-8", null);
}
else
{
Toast.makeText(getActivity(),"No Internet. Please Connect to Network...",Toast.LENGTH_SHORT).show();
}
return v;
}