简体   繁体   English

.NET MAUI 7 - AbsoluteLayout 中的按钮在 Android 中不起作用

[英].NET MAUI 7 - Button in AbsoluteLayout not working in Android

As shown below, I created a button in the lower right corner with an absolute layout.如下图,我在右下角创建了一个按钮,绝对布局。 The thing is, it doesn't work on Android.问题是,它不适用于 Android。 It shows up but instead presses the recipe below.它出现了,而是按下了下面的食谱。 On Windows App everything is working as expected.在 Windows 应用程序上,一切都按预期工作。

在此处输入图像描述

Here is the code:这是代码:

<FlexLayout>
    <RefreshView IsRefreshing="{Binding IsRefreshing}" Command="{Binding RefreshRecipes}">

        <CollectionView >
            ...
        </CollectionView>
    </RefreshView>
    <AbsoluteLayout MaximumWidthRequest="0" >
        <Button AbsoluteLayout.LayoutBounds="1, 1, 100, 100"
                AbsoluteLayout.LayoutFlags="PositionProportional"
                Text="+"
                Command="{Binding AddRecipeCommand}"
                FontSize="Large"
                BackgroundColor="DodgerBlue"
                TextColor="White"
                CornerRadius="25"
                HeightRequest="50"
                WidthRequest="50" 
                ZIndex="100"/>
    </AbsoluteLayout>
</FlexLayout>

I'm aware the MaximumWidthRequest="0" might cause a problem, but I don't know what else to do.我知道MaximumWidthRequest="0"可能会导致问题,但我不知道还能做什么。

Change the FlexLayout to a Grid.将 FlexLayout 更改为网格。 Then you delete the AbsoluteLayout and set the VerticalOptions and the HorizontalOptions to End.然后删除 AbsoluteLayout 并将 VerticalOptions 和 HorizontalOptions 设置为 End。 That is the way how I do it.我就是这样做的。

If this doesn't work, you have to show your xaml.cs code and the ViewModel code.如果这不起作用,您必须显示您的 xaml.cs 代码和 ViewModel 代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM