Problems with the interface when rotating the device horizontally

ephramdephramd ESMember ✭✭

Hi!

The interface of my application is divided into a header (it is a webview) and absolute content, which among other things contains a second webview.

In vertical orientation it works and looks perfect.

But when I turn the device horizontally the header stops measuring 70 and measures something like 30 ....
The header reduces the height although it has a fixed height.

Why this happen? Any solution?
Thanks!

`
<ContentPage.Content>

        <WebView x:Name="webview_header" HorizontalOptions="FillAndExpand" HeightRequest="70" BackgroundColor="Red"/>

        <AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BackgroundColor="Black">
            <!-- other things -->
            <ScrollView AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" BackgroundColor="Green">
                <AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Padding="0" BackgroundColor="Purple">
                    <WebView x:Name="webview" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" BackgroundColor="Blue" />
                </AbsoluteLayout>
            </ScrollView>
        </AbsoluteLayout>

    </StackLayout>
</ContentPage.Content>

`

Posts

  • ShantimohanElchuriShantimohanElchuri USMember ✭✭✭✭✭

    @ephramd What you are setting is HeightRequest and not Height itself. You can only request what you want but it is not guaranteed that it will be granted. So you are not setting a Fixed Height.

    I have not used either WebView or the AbsoluteLayout. So I can't say how they affect the Height allocation.

    But you can try placing the two WebViews in a Grid. Check if something like given below is of any help.

    <ContentPage.Content>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
    
            <WebView Grid.Row="0" x:Name="webview_header" ... ... ... />
    
            <WebView Grid.Row="1" x:Name="webview" ... ... ... />
        </Grid>
    </ContentPage.Content>
    
Sign In or Register to comment.