Xamarin: Android WebView загружает часть экрана - PullRequest
0 голосов
/ 02 июля 2019

Я пытаюсь загрузить веб-страницу входа в HybridWebview из примера кода.

На странице как-то отображается только часть показанного html: enter image description here

Код, который у меня есть:

const string JavascriptFunction = "function invokeCSharpAction(data){jsBridge.invokeAction(data);}";
    Context _context;

    public HybridWebViewRenderer(Context context) : base(context)
    {
        _context = context;
    }

    protected override void OnElementChanged(ElementChangedEventArgs<HybridWebView> e)
    {
        base.OnElementChanged(e);

        if (e.OldElement != null)
        {
            Control.RemoveJavascriptInterface("jsBridge");
            var hybridWebView = e.OldElement as HybridWebView;
            hybridWebView.Cleanup();
        }
        if (e.NewElement != null)
        {
            if (Control == null)
            {
                var webView = new Android.Webkit.WebView(_context);
                webView.SetY(500);
                webView.Settings.JavaScriptEnabled = true; 
                webView.Settings.DomStorageEnabled = true; 
                webView.VerticalScrollBarEnabled = true;
                webView.SetWebViewClient(new JavascriptWebViewClient($"javascript: {JavascriptFunction}"));
                SetNativeControl(webView);
            }
            Control.AddJavascriptInterface(new JSBridge(this), "jsBridge");
            Control.LoadUrl(Element.Uri);
        }
    }

Синий фон - это фон веб-просмотра. Я опускаю дисплей вниз, чтобы увидеть, скрыт ли остальной экран сверху.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...