Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HorizontalListView] Can't set padding correctly #64

Closed
bnserig opened this issue Jun 28, 2019 · 2 comments

Comments

@bnserig
Copy link

commented Jun 28, 2019

  • OS: Android
  • Device: Huawei P20 Lite
  • Sdk vervion: Android SDK 27
  • Xamarin.Forms: 3.6.0.344447

I have a weird problem with HorizontalListview. It seems that it has a padding between HorizontalListView and the ViewCell inside.

I am using this code :

    <Grid RowSpacing="0">
        <Grid.RowDefinitions>
            <RowDefinition Height="100" />
            <RowDefinition Height="*" />
            <RowDefinition Height="100" />
        </Grid.RowDefinitions>

        <StackLayout
            Grid.Row="0"
            BackgroundColor="Red"
            HorizontalOptions="FillAndExpand"
            VerticalOptions="FillAndExpand" />

        <renderedViews:HorizontalListView
            x:Name="FruitList"
            Grid.Row="1"
            BackgroundColor="Green"
            CollectionPadding="0"
            ColumnCount="1"
            HorizontalOptions="FillAndExpand"
            ItemSpacing="0"
            ListLayout="Linear"
            ScrollSpeed="Slowest"
            SnapStyle="Center"
            VerticalOptions="FillAndExpand">
            <renderedViews:HorizontalListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <Label
                            Grid.Row="0"
                            BackgroundColor="Blue"
                            HorizontalOptions="FillAndExpand"
                            HorizontalTextAlignment="Center"
                            Text="{Binding .}"
                            VerticalOptions="FillAndExpand"
                            VerticalTextAlignment="Center" />
                    </ViewCell>
                </DataTemplate>
            </renderedViews:HorizontalListView.ItemTemplate>
        </renderedViews:HorizontalListView>

        <StackLayout
            Grid.Row="2"
            BackgroundColor="Red"
            HorizontalOptions="FillAndExpand"
            VerticalOptions="FillAndExpand" />

    </Grid>

And the result is this :
Screenshot_20190628-161933

I don't understand why the backgroundcolor of the Label (blue) doesn't cover all the HorizontalListView (green).

If someone have a solution...
Thanks

@roubachof roubachof added this to To do in Kanban board Jul 2, 2019
@bnserig

This comment has been minimized.

Copy link
Author

commented Jul 2, 2019

It works when I set Margin="0,-2,0,0" on the HorizontalListView.

@roubachof

This comment has been minimized.

Copy link
Owner

commented Aug 27, 2019

It was caused by dp to pixel conversion accuracy. I'm afraid it will persist in some cases.

@roubachof roubachof moved this from To do to Done in Kanban board Aug 27, 2019
@roubachof roubachof closed this in 564bc44 Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
2 participants
You can’t perform that action at this time.