0

I use WebView in Xamarin Forms like this:

    <ContentPage.Content>
        <local:HybridWebView x:Name="hybridWebView" Uri="https://code4nara.github.io/Maplat/?appid=jizoapp&amp;overlay=true" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" />
    </ContentPage.Content>

But in side of this webview, height of http body shrinks to 0, so css "height:100%" or so not works. I searched about thi issue, This article is found. Android WebView: how to let the css use the entire height w/ position absolute? It says,

android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"

causes webview body's height 0px.

android:layout_width="match_parent"
android:layout_height="match_parent"

works well.

So, I believe Xamarin Forms' "VerticalOptions="FillAndExpand"" uses "android:layout_alignParentXXX" instead of "android:layout_height="match_parent"". Is there any way to make sure to use "android:layout_height="match_parent"" by Xamarin.Forms?

Regards,

Kohei

kochizufan
  • 2,120
  • 2
  • 30
  • 50

1 Answers1

1

Looking at the Android implementation (line 70 - 75) of the WebViewRenderer in Xamarin.Forms I can see that in fact match_parent is the default height and width when creating the native WebView Control.

Working with Xamarin.Forms anytime you need to do something very specific for a platform you can do it with CustomRenderers.

Here you can subclass the WebViewRenderer and modify to your needs.

pinedax
  • 9,246
  • 2
  • 23
  • 30