Java Code Examples for android.webkit.WebSettings#setDefaultFontSize()
The following examples show how to use
android.webkit.WebSettings#setDefaultFontSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppRouter.java From FriendBook with GNU General Public License v3.0 | 6 votes |
/** * @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); }
Example 2
Source File: WebActivity.java From NewsMe with Apache License 2.0 | 6 votes |
private void initView() { getBinding().swipe.setOnSwipeBackListener(this); // WebView WebSettings webSettings = getBinding().web.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setBuiltInZoomControls(false); webSettings.setSupportZoom(false); webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); webSettings.setDefaultFontSize(18); getBinding().web.setWebViewClient(new MeWebViewClient()); getBinding().web.setWebChromeClient(new MeWebChromeClient()); getBinding().web.loadUrl(getIntent().getStringExtra(INTENT_URL)); // ProgressBar // Title if (mTitle != null && !mTitle.equals("")) { getBinding().toolbar.setTitle(mTitle); } else { getBinding().toolbar.setTitle(R.string.loading); } }
Example 3
Source File: BrowserFragment.java From CoreModule with Apache License 2.0 | 6 votes |
@SuppressLint({"SetJavaScriptEnabled"}) public static void initWebView(WebView webView) { WebSettings settings = webView.getSettings(); settings.setDefaultFontSize(15); settings.setJavaScriptEnabled(true); settings.setSupportZoom(true); settings.setBuiltInZoomControls(true); int sysVersion = Build.VERSION.SDK_INT; if (sysVersion >= 19) { webView.getSettings().setLoadsImagesAutomatically(true); } else { webView.getSettings().setLoadsImagesAutomatically(false); } settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); if (sysVersion >= 11) { settings.setDisplayZoomControls(false); } else { ZoomButtonsController zbc = new ZoomButtonsController(webView); zbc.getZoomControls().setVisibility(View.GONE); } addWebImageShow(webView.getContext(), webView); }
Example 4
Source File: BrowserDelegateOption.java From CoreModule with Apache License 2.0 | 6 votes |
@SuppressLint({"SetJavaScriptEnabled"}) public static void initWebView(WebView webView) { WebSettings settings = webView.getSettings(); settings.setDefaultFontSize(15); settings.setJavaScriptEnabled(true); settings.setSupportZoom(true); settings.setBuiltInZoomControls(true); int sysVersion = Build.VERSION.SDK_INT; if (sysVersion >= 19) { webView.getSettings().setLoadsImagesAutomatically(true); } else { webView.getSettings().setLoadsImagesAutomatically(false); } settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); if (sysVersion >= 11) { settings.setDisplayZoomControls(false); } else { ZoomButtonsController zbc = new ZoomButtonsController(webView); zbc.getZoomControls().setVisibility(View.GONE); } addWebImageShow(webView.getContext(), webView); }
Example 5
Source File: ExtendedWebView.java From ForPDA with GNU General Public License v3.0 | 6 votes |
@SuppressLint("SetJavaScriptEnabled") public void init() { mUiThread = Thread.currentThread(); audioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); addJavascriptInterface(this, IBase.JS_BASE_INTERFACE); WebSettings settings = getSettings(); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); settings.setBuiltInZoomControls(false); settings.setDefaultFontSize(16); settings.setTextZoom(100); settings.setJavaScriptEnabled(true); settings.setAllowFileAccess(true); settings.setAllowContentAccess(true); settings.setAllowFileAccessFromFileURLs(true); settings.setAllowUniversalAccessFromFileURLs(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } setRelativeFontSize(Preferences.Main.getWebViewSize(getContext())); setBackgroundColor(App.getColorFromAttr(getContext(), R.attr.background_base)); }
Example 6
Source File: WebViewHelper.java From AndroidReview with GNU General Public License v3.0 | 6 votes |
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; } }); }
Example 7
Source File: BaseDetailFragment.java From Cotable with Apache License 2.0 | 6 votes |
@SuppressLint({"SetJavaScriptEnabled", "JavascriptInterface"}) @TargetApi(Build.VERSION_CODES.HONEYCOMB) protected void initWebView(WebView webView) { WebSettings settings = webView.getSettings(); settings.setDefaultFontSize(15); settings.setJavaScriptEnabled(true); settings.setSupportZoom(true); settings.setBuiltInZoomControls(true); int sysVersion = Build.VERSION.SDK_INT; if (sysVersion >= 11) { settings.setDisplayZoomControls(false); } else { ZoomButtonsController zbc = new ZoomButtonsController(webView); zbc.getZoomControls().setVisibility(View.GONE); } }
Example 8
Source File: FunctionUtils.java From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("static-access") public static void handleContentTV(final WebView contentTV, final MessageArticlePageInfo row, int bgColor, int fgColor, Context context) { final WebViewClient client = new WebViewClientEx((FragmentActivity) context); contentTV.setBackgroundColor(0); contentTV.setFocusableInTouchMode(false); contentTV.setFocusable(false); contentTV.setLongClickable(false); WebSettings setting = contentTV.getSettings(); setting.setUserAgentString(context.getString(R.string.clientua) + BuildConfig.VERSION_CODE); setting.setDefaultFontSize(PhoneConfiguration.getInstance() .getWebSize()); setting.setJavaScriptEnabled(false); contentTV.setWebViewClient(client); contentTV.setTag(row.getLou()); contentTV.loadDataWithBaseURL(null, row.getFormated_html_data(), "text/html", "utf-8", null); }
Example 9
Source File: UIHelper.java From KJFrameForAndroid with Apache License 2.0 | 6 votes |
@SuppressLint({ "JavascriptInterface", "SetJavaScriptEnabled" }) public static void initWebView(WebView webView) { WebSettings settings = webView.getSettings(); settings.setDefaultFontSize(15); settings.setJavaScriptEnabled(true); settings.setSupportZoom(true); settings.setBuiltInZoomControls(true); 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(UIHelper.getWebViewClient()); }
Example 10
Source File: SubscriptionDetailsFragment.java From redgram-for-reddit with GNU General Public License v3.0 | 5 votes |
private void setupWebViewSettings() { final WebSettings webSettings = subredditDesc.getSettings(); Resources res = getResources(); float fontSize = res.getDimension(R.dimen.web_text); webSettings.setDefaultFontSize((int) fontSize); webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); webSettings.setAppCacheEnabled(false); webSettings.setBlockNetworkImage(true); webSettings.setLoadsImagesAutomatically(true); webSettings.setGeolocationEnabled(false); webSettings.setNeedInitialFocus(false); webSettings.setSaveFormData(false); }
Example 11
Source File: WebViewActivity.java From PLDroidShortVideo with Apache License 2.0 | 4 votes |
@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); } }