0

After implementing a WebView with one line of code everything is working fine:

<WebView HorizontalOptions="FillAndExpand"
         VerticalOptions="FillAndExpand"
         BackgroundColor="Red"
         x:Name="wbview"
         Source="www.google.de"/>

If I change the Source to https://my.source.com:1234/ it's not getting displayed on Android, but on iOS, the website is displayed correctly. What am I missing? Is it some design failures in my styles.xaml?

Change Url to my Url => working on ios not android

Jan Schultke
  • 17,446
  • 6
  • 47
  • 96
Pascal
  • 79
  • 1
  • 5

2 Answers2

0

Is this what you are looking for?

wbview.Source = $"https://my.source.com:1234/";

From the docs: The Source property can be set to an UrlWebViewSource object or a HtmlWebViewSource object, which both derive from WebViewSource. A UrlWebViewSource is used for loading a web page specified with a URL, while a HtmlWebViewSource object is used for loading a local HTML file, or local HTML.

Also, note that the WebView height may have zero height. Add a container to auto grow the Webview to your screen.

<Grid>
   <WebView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
                     BackgroundColor="Red" x:Name="wbview" Source="www.google.de"/>

</Grid>

Source: Microsoft Learn

Isidoros Moulas
  • 520
  • 3
  • 10
0

Starting with Android 9 (API level 28), cleartext support is disabled by default.

So cleartext traffic will be automatically blocked by the system when user access the domains which needs to communicate with over HTTPS.

For more information, you can refer to this case about Android 8: Cleartext HTTP traffic not permitted and this one about android webview displaying blank page specific url only

Liyun Zhang - MSFT
  • 8,271
  • 1
  • 2
  • 14