我正在尝试使用从此处HybridWebView
取得的https://github.com/xamarin/xamarin-forms-samples/tree/master/CustomRenderers/HybridWebView来显示网站的Webview>
XAML:
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:PortaleDocumenti.Xamarin" x:Class="PortaleDocumenti.Xamarin.MainPage"> <ContentPage.Content> <local:HybridWebView x:Name="hybridWebView" Uri="https://ej2.syncfusion.com/demos/grid/grid-overview/index.html" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"/> </ContentPage.Content> </ContentPage>
当显示页面时,宽度和高度不是手机显示屏的整个视口,并且显示不正确(似乎正在作为桌面版本使用,如果我在浏览器中将其打开,则工作正常。
URL例如如下:https://ej2.syncfusion.com/demos/grid/grid-overview/index.html
Currenlty我正在三星S10上对其进行测试。
如果要从运行良好的Cordova应用程序中迁移,请执行以下操作:
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Security-Policy" content="default-src *; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'; img-src * data: 'unsafe-inline'; connect-src * 'unsafe-inline'; frame-src *;"> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta name="format-detection" content="telephone=no"> <meta name="msapplication-tap-highlight" content="no"> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> <link rel="stylesheet" type="text/css" href="css/index.css"> <title>Demo</title> </head> <body> <div class="app"> <h1>Apache Cordova</h1> <div id="deviceready" class="blink"> <p class="event listening">Connecting to Device</p> <p class="event received">Device is Ready</p> </div> </div> <script type="text/javascript" src="cordova.js"></script> <script type="text/javascript" src="scripts/platformOverrides.js"></script> <script type="text/javascript" src="scripts/index.js"></script> </body> </html>
和
InAppBrowser
以这种方式在onDeviceReady
中设置:
var myRef = cordova.InAppBrowser.open('https://ej2.syncfusion.com/demos/grid/grid-overview/index.html', '_blank', 'location=no,toolbar=no,zoom=no');
我正在尝试使用从此处https://github.com/xamarin/xamarin-forms-samples/tree/master/CustomRenderers/HybridWebView XAML获取的HybridWebView来显示网站的Webview: