How to have a full-size stacklayout within a absolutelayout

TheMillerTheMiller USMember ✭✭
edited March 2018 in Xamarin.Forms

Hello there!

I encounter a width-problem, that I broke down to AbsoluteLayout and StackLayout. At first, I wanted to integrate AdMob-Banner-Ads. In general, they are displayed correctly. But when I place them within a StackLayout (which itself is in a AbsoluteLayout), AdMob says "Not enough space for the ad banner".
And I am "forced" to have an AbsoluteLayout because I want to show an ActivityIndicator-Popup while fetching data.

My Layout is the following:

-ContentPage
    -AbsoluteLayout
        -AdMobView
        -StackLayout
            -SearchBar
            -[Alternatively here the AdMobView]
            -ListView

in xaml it is the code

<ContentPage.Content>
    <AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">

        <!-- AdMob -->
        <ads:AdMobView AdUnitId="{Binding AdUnitId}" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,1" />

        <StackLayout AbsoluteLayout.LayoutFlags="SizeProportional"  AbsoluteLayout.LayoutBounds="0,0,1,1" Orientation="Vertical" IsEnabled="True">
            <SearchBar Placeholder="Find ..." Text="{Binding SearchText}">
                    <SearchBar.Behaviors>
                        <cmd:EventToCommandBehavior EventName="TextChanged" Command="{Binding SearchCommand}" />
                    </SearchBar.Behaviors>
                </SearchBar>
        ....
        ....
        </StackLayout>
        <!-- ActivityIndicator Popup -->
        <StackLayout IsVisible="{Binding ShowActivityIndicator}" AbsoluteLayout.LayoutFlags="PositionProportional" AbsoluteLayout.LayoutBounds="0.5,0.5,-1,-1">
                <Frame CornerRadius="10" HasShadow="False" BackgroundColor="#BB000000">
                    <ActivityIndicator Color="White" WidthRequest="80" HeightRequest="80" IsRunning="{Binding ShowActivityIndicator}" VerticalOptions="Center" HorizontalOptions="Center" />
                </Frame>
            </StackLayout>
    </AbsoluteLayout>
</ContentPage.Content>

I hope somebody can help me. I checked my margins and padding to be 0px. Outside the AbsoluteLayout the Adbanner is being displayed. Somewhere some pixels "are getting ate", so that the isn't the full-width available, but AdMob needs the full-width. I have no idea what to do/test now.

Thanks in advance

Answers

Sign In or Register to comment.