Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ListView Xamarin.Forms(Android)中的图像溢出_Android_Image_Xamarin_Xamarin.forms_Xamarin.android - Fatal编程技术网

ListView Xamarin.Forms(Android)中的图像溢出

ListView Xamarin.Forms(Android)中的图像溢出,android,image,xamarin,xamarin.forms,xamarin.android,Android,Image,Xamarin,Xamarin.forms,Xamarin.android,有一个列表视图,其中对于列表的每个元素,您有3个按钮用于3个不同的选项,当您进入屏幕时,ImageButton的图像中没有溢出问题,但是当您进行第一次滚动时,源开始溢出,如下图所示 当你上下滚动时,图像会失去中心,并且没有对齐,这个问题在iOS中不会出现,只会在Android(版本6、7、8和9)中出现,显然这是一个类似于Android渲染图像的问题 我尝试过,将ImageButton控件更改为Button,但问题仍然存在,还尝试将“Aspect”属性分配给ImageButton,但没有获得成

有一个列表视图,其中对于列表的每个元素,您有3个按钮用于3个不同的选项,当您进入屏幕时,ImageButton的图像中没有溢出问题,但是当您进行第一次滚动时,源开始溢出,如下图所示

当你上下滚动时,图像会失去中心,并且没有对齐,这个问题在iOS中不会出现,只会在Android(版本6、7、8和9)中出现,显然这是一个类似于Android渲染图像的问题

我尝试过,将ImageButton控件更改为Button,但问题仍然存在,还尝试将“Aspect”属性分配给ImageButton,但没有获得成功的结果,有任何帮助如何解决此问题?然后我的代码是XAML

   <ListView 
                ItemsSource="{Binding ListaRecintos}"
                SelectionMode="None"
                IsRefreshing="{Binding IsRefreshing, Mode=TwoWay}"        
                             RowHeight="80"
                             HasUnevenRows="True">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <StackLayout
                                    Margin="0,4,0,0"
                                Orientation="Vertical">

                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="1*"/>
                                            <ColumnDefinition Width="3.9*"/>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>


                                        <Label
                                            Text="{Binding Code}" 
                                            HorizontalOptions="Start" 
                                            FontSize="Small" 
                                            WidthRequest="40"
                                            HeightRequest="30"
                                            FontAttributes="Bold"
                                            VerticalTextAlignment="Center"
                                            HorizontalTextAlignment="Center"
                                            TextColor="{StaticResource das.color.texto}"
                                            VerticalOptions="CenterAndExpand"
                                            Grid.Column="0">
                                        </Label>

                                        <StackLayout Orientation="Vertical"
                                                      Grid.Column="1">
                                             <Label                                 
                                            Text="{Binding Name}"
                                            HorizontalOptions="Start" 
                                            FontSize="Small" 
                                            HeightRequest="32"
                                            MaxLines="2"
                                            TextColor="{StaticResource das.color.texto}"
                                            VerticalOptions="Center"
                                            VerticalTextAlignment="Center">
                                        </Label>
                                        </StackLayout>
                                    </Grid>

                                    <!--STACK BUTTON-->
                                    <StackLayout
                                              Orientation="Horizontal"
                                              HorizontalOptions="EndAndExpand"
                                              Margin="0,1,1,0">

                                        <!--BUTTON 1-->
                                        <ImageButton 
                                            Source="ic_check_wt"
                                            Aspect="AspectFit"
                                            CornerRadius="0"
                                            BackgroundColor="{StaticResource das.color.estado_success}"                                            
                                            HorizontalOptions="End"
                                            VerticalOptions="Center"
                                            HeightRequest="35"
                                            WidthRequest="50"
                                            CommandParameter="2"
                                            Command="{Binding ControlAuditoriaCommand}"
                                            IsEnabled="{Binding EnabledButton}"/>

                                        <!--BUTTON 2-->
                                        <ImageButton 
                                            Source="ic_hammer"                                         
                                            BackgroundColor="{StaticResource das.color.estado_primary}"                                        
                                            HorizontalOptions="End"
                                            CornerRadius="0"
                                            Aspect="AspectFit"
                                            VerticalOptions="Center"
                                            HeightRequest="35"
                                            WidthRequest="50"
                                            CommandParameter="1"
                                            Command="{Binding ControlAuditoriaCommand}"
                                            IsEnabled="{Binding EnabledButton}"/>

                                        <!--BUTTON 3-->
                                        <ImageButton 
                                            Source="ic_arrow_up"
                                            BackgroundColor="{StaticResource das.color.estado_success}"                                           
                                            HorizontalOptions="End"
                                            CornerRadius="0"
                                            Aspect="AspectFit"
                                            VerticalOptions="Center"
                                            HeightRequest="35"
                                            WidthRequest="50"
                                            CommandParameter="3"
                                            Command="{Binding ControlAuditoriaCommand}"
                                            IsEnabled="{Binding EnabledButton}"/>

                                    </StackLayout>
                                </StackLayout>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>


我怎样才能避免这种行为?有什么帮助吗?

我建议您使用(Frame+image)而不是ImageButton,并在其上添加Tap手势

你的表格版本是什么?预期的图像是什么?如果可能的话,你能为我们提供一个基本的项目进行测试吗?我的Xamarin.Forms版本是4.3.0.947036。我期望的图像是以图像为中心的,没有变形,不幸的是,我不能提供有问题的项目,因为它来自我工作的公司。有什么帮助吗@ColeXia MSFTI建议您使用(帧+图像)而不是ImageButton,并在其上添加TapSirture。您的解决方案是正确的!应用该按钮以响应将其标记为正确@ColeXia msft该按钮如何覆盖​​镜框?当我把框架+按钮,我有太多的空间之间的按钮和框架,我会解释吗@科尔西亚