dotnet / dotnet/maui

WebView inside a StackLayout height calculation differs between Windows and Android.

Open
#5,799 7 comments 0 reactions 0 assignees View on GitHub
area-layout legacy-area-controls platform/android platform/windows s/triaged s/verified t/bug
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 15h
Merged PRs (30d)
290

Description

### Description

If you put a WebView inside a StackLayout the alloted height differs between Windows and Android. Without specifying the height, it can't be seen at all on Windows as it is assigned a height of 0. On Android, it takes whatever space is needed to display the website.
If you set a MinimumHeightRequest you can see the WebView with that height and a vertical scroll bar on Windows. On Android, it again uses whatever space is necessary to display the page.

### Steps to Reproduce

1. Create a content page with the following XAML:
```



```

2. Display it. It's completely green on Windows, on Android it displays the full Google website in the upper part and is green in the lower part of the view.

3. Add `MinimumHeightRequest="200"` to the WebView. On Windows, you see a 200 "pixels" high Google website in which you can scroll vertically. On Android, again, the full Google page is visible on the top and the remainder is filled with the green background.

### Version with bug

Preview 14 (current)

### Last version that worked well

Unknown/Other

### Affected platforms

Android, Windows

### Affected platform versions

Windows 10.0.19041, Android 7 (API 24), Android 12 (API 31)

### Did you find any workaround?

_No response_

### Relevant log output

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the supplied ContentPage XAML containing a WebView inside a StackLayout, and reproduce the height allocation on Windows and Android. Compare the platform-specific measurement behavior, then verify that the WebView receives a usable and consistent height without requiring MinimumHeightRequest on either platform.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, csharp
Domain
desktop-dev, frontend, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.