Button event not always firing when used in absolute layout on Android Nougat 7.1.2 device

IrgiIrgi USMember ✭✭

I have a strange behavior when using AbsoluteLayout in Xamarin.Forms 2.5.1.444934 which only seems to affect a device running Nougat 7.1.2. I cannot reproduce the problem with a 7.1-Emulator.
The loginButton is bound to a command in the code. The code is working fine with this XAML layout:

        <StackLayout Padding="10" HorizontalOptions="Center">
            <Image x:Name="login_icon" HeightRequest="50" Aspect="AspectFit" HorizontalOptions="CenterAndExpand"></Image>
            <StackLayout Padding="10">
                <Label Text="{i18n:Translate UsernameLabel}" TextColor="#0B4786"></Label>
                <Entry Text="{Binding UserName, Mode=TwoWay}" x:Name="usernameEntry" BackgroundColor="#EEEEEE" TextColor="#0B4786"></Entry>
                <Label Text="{i18n:Translate PasswordLabel}" TextColor="#0B4786"></Label>
                <Entry Text="{Binding Password, Mode=TwoWay}" IsPassword="True" BackgroundColor="#EEEEEE" TextColor="#0B4786"></Entry>
                <Button Text="{i18n:Translate LoginButton}" Command="{Binding Login}" x:Name="loginButton" CommandParameter="0" Margin="0,50,0,0" ></Button>
                <Label x:Name="statusLabel" IsVisible="False" Style="{DynamicResource propLabelStyle}"></Label>
            </StackLayout>
        </StackLayout>

I then changed the XAML to an absolute layout to display a small icon in the lower right corner of the page.
The page look fine on alle devices and works on (as far as I know so far) on all plattforms except a ZEBRA TC 25 . On this device, i have to click on the button more than ten times in a row to fire the event. I seems like the button is not active all the time or sporadically somehow overlayed by something else.
Here's the XAML:

<AbsoluteLayout>
        <StackLayout AbsoluteLayout.LayoutBounds="0.5,0.0,0.5,0.9" AbsoluteLayout.LayoutFlags="All" >
            <StackLayout HeightRequest="30">
                <views:LoadingIndicator>
                </views:LoadingIndicator>
            </StackLayout>
            <AbsoluteLayout>
                <Image x:Name="login_icon" AbsoluteLayout.LayoutBounds="0.5,0,0.3,0.3" AbsoluteLayout.LayoutFlags="All"></Image>
                <StackLayout Padding="10" AbsoluteLayout.LayoutBounds="0,0.6,1,0.6" AbsoluteLayout.LayoutFlags="All" >
                <Label Text="{i18n:Translate UsernameLabel}" TextColor="#0B4786"></Label>
                <Entry Text="{Binding UserName, Mode=TwoWay}" x:Name="usernameEntry" BackgroundColor="#EEEEEE" TextColor="#0B4786"></Entry>
                <Label Text="{i18n:Translate PasswordLabel}" TextColor="#0B4786"></Label>
                <Entry Text="{Binding Password, Mode=TwoWay}" IsPassword="True" BackgroundColor="#EEEEEE" TextColor="#0B4786"></Entry>
                                   <Button Text="{i18n:Translate LoginButton}" Command="{Binding Login}" x:Name="loginButton" CommandParameter="0" Margin="0,50,0,0" ></Button>
                <Label x:Name="statusLabel" IsVisible="False" Style="{DynamicResource propLabelStyle}"></Label>
            </StackLayout>
            </AbsoluteLayout>
        </StackLayout>
        <Image x:Name="logoCut" AbsoluteLayout.LayoutBounds="1.0,1.0,0.1,0.1" AbsoluteLayout.LayoutFlags="All"></Image>
    </AbsoluteLayout>

Any idea, what may cause the problem or how I may gather some more information from debug output?

Answers

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    My first thought is the math is off and the button active area is nearly off screen.
    As a test, make the button background something plainly obvious like fuschia or neon green. Then re-run it.
    Also consider something else might be on top of the button and blocking 90% of its surface. If you make all your controls brightly colored for testing it makes it easier to see what is where.
    On android in devleoper mode you can also turn on "show bounding boxes" and have the android device outline every element so you can see their active areas.
    Its a place to start at least.

Sign In or Register to comment.