Exemplo n.º 1
0
 public void SetFontSize(WebContentFontSize size)
 {
     if (webView != null)
     {
         webView.Settings.TextZoom = WebContentFontSizeHelper.ParseZoom(size);
     }
 }
Exemplo n.º 2
0
        public WebViewExt RequestWebView(
            Context context,
            Action onPageLoaded = null,
            Action <string, string, float, float, float, float> onGetSelectedText = null,
            Action <Hyperlink> onLoadUrl              = null,
            Action <int, float> onWebOverScroll       = null,
            Action <string> onScrollLoadPageCompleted = null,
            Action <string, string> onScrollToPage    = null)
        {
            if (webView == null)
            {
                webView = new WebViewExt(context);
                webView.SetLayerType(LayerType.Software, null);
                webView.LayoutParameters = new ViewGroup.LayoutParams(
                    ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
                webView.Settings.JavaScriptEnabled = true;
                webView.SetWebViewClient(webViewClient);
                webView.Settings.TextZoom = WebContentFontSizeHelper.ParseZoom((int)SettingsUtil.Instance.GetFontSize());
                webView.AddJavascriptInterface(new RedController(this, webView), "RedController");
                webView.SetOverScrollHandler(OnWebOverScroll);
                webView.ScrollbarFadingEnabled = false;
            }

            if (parentView != null)
            {
                throw new InvalidOperationException("The WebView is loan out.");
            }

            this.onPageLoaded              = onPageLoaded;
            this.onGetSelectedText         = onGetSelectedText;
            this.onWebOverScroll           = onWebOverScroll;
            this.onScrollLoadPageCompleted = onScrollLoadPageCompleted;
            this.onScrollToPage            = onScrollToPage;
            this.onLoadUrl = onLoadUrl;

            return(webView);
        }