浮动操作按钮在ListView上无法正常工作

时间:2022-01-03 19:43:15

I have a floating action button over a listview. When the list is empty or with fewer entries floating action button works fine, but when the list fills up floating action button gets unclickable. In this situation, when I try to click floating action button the list item gets clicked.

我在列表视图上有一个浮动操作按钮。当列表为空或具有较少条目的浮动操作按钮工作正常,但当列表填满浮动操作按钮变得无法点击时。在这种情况下,当我尝试单击浮动操作按钮时,单击列表项。

  <AbsoluteLayout>
            <StackLayout AbsoluteLayout.LayoutBounds="0, 0, 1, 1" AbsoluteLayout.LayoutFlags="All">
                <ListView IsPullToRefreshEnabled="{Binding CanExecute}"
                          IsRefreshing="{Binding CanExecute, Converter={StaticResource xyzConverter}}"
                          ItemsSource="{Binding Assessments, Converter={StaticResource abcConverter}}"
                          IsEnabled="{Binding CanExecute}"
                          HasUnevenRows="True"
                          x:Name="ListContent">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <Grid HeightRequest="34"
                                      Padding="16, 20, 16, 20"
                                      RowSpacing="0">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="18" />
                                        <RowDefinition Height="16" />
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="24" />
                                        <ColumnDefinition Width="48" />
                                    </Grid.ColumnDefinitions>
                                    <Label HorizontalTextAlignment="Start"
                                       VerticalTextAlignment="End"
                                       FontSize="16"
                                       FontAttributes="Bold"
                                       LineBreakMode="WordWrap"
                                       Grid.Column="0"
                                       Grid.Row="0"
                                       Text="{Binding Name}"/>
                                </Grid>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </StackLayout>
            <Custom:FloatingActionButtonView 
                AbsoluteLayout.LayoutBounds="1, 1, AutoSize, AutoSize"
                AbsoluteLayout.LayoutFlags="PositionProportional"
                HasShadow="True"
                Size="Normal"
                ImageName="new.png"
                x:Name="FAB"
                ColorNormal="{x:Static Constants:Colors.Primary}"
                Command="{Binding MyCommand}"/>
        </AbsoluteLayout>

1 个解决方案

#1


0  

Try this out, inserting your button inside a StackLayout

试试这个,将你的按钮插入StackLayout

<StackLayout>
    <Custom:FloatingActionButtonView 
                AbsoluteLayout.LayoutBounds="1, 1, AutoSize, AutoSize"
                AbsoluteLayout.LayoutFlags="PositionProportional"
                HasShadow="True"
                Size="Normal"
                ImageName="new.png"
                x:Name="FAB"
                ColorNormal="{x:Static Constants:Colors.Primary}"
                Command="{Binding MyCommand}"/>
</StackLayout>

#1


0  

Try this out, inserting your button inside a StackLayout

试试这个,将你的按钮插入StackLayout

<StackLayout>
    <Custom:FloatingActionButtonView 
                AbsoluteLayout.LayoutBounds="1, 1, AutoSize, AutoSize"
                AbsoluteLayout.LayoutFlags="PositionProportional"
                HasShadow="True"
                Size="Normal"
                ImageName="new.png"
                x:Name="FAB"
                ColorNormal="{x:Static Constants:Colors.Primary}"
                Command="{Binding MyCommand}"/>
</StackLayout>