Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Android] ItemSpacing on CarouselView resizes items #29609

@ewerspej

Description

@ewerspej

Description

When using a LinearItemsLayout with a CarouselView on Android, the ItemSpacing will reduce the width of the elements in the CarouselView. This works correctly on iOS.

Screenshots

iOS (correct):

Android (incorrect):

Code

<CarouselView
  BackgroundColor="Red"
  HeightRequest="400"
  ItemsSource="{Binding Items}"
  WidthRequest="300">
  <CarouselView.ItemsLayout>
    <LinearItemsLayout
      ItemSpacing="50"
      Orientation="Horizontal"
      SnapPointsAlignment="Center"
      SnapPointsType="MandatorySingle" />
  </CarouselView.ItemsLayout>
  <CarouselView.ItemTemplate>
    <DataTemplate x:DataType="{x:Type system:String}">
      <Grid
        Margin="0"
        Padding="0"
        BackgroundColor="Yellow">
        <Label
          FontSize="24"
          HorizontalOptions="Center"
          Text="{Binding}"
          VerticalOptions="Center" />
      </Grid>
    </DataTemplate>
  </CarouselView.ItemTemplate>
</CarouselView>

Steps to Reproduce

  1. Create a new MAUI project
  2. Add a CarouselView
  3. Add a LinearItemsLayout and set ItemSpacing = "50"
  4. Add a collection with some data and bind to it
  5. Run on Android
  6. The items get smaller the larger the ItemSpacing is

Expected behavior: Item spacing is applied between elements without shrinking their width
Current behavior: Items get shrunk on Android, spacing isn't applied between items

Link to public reproduction project repository

https://github.com/ewerspej/MauiCarouselSpacingBugAndroid

Version with bug

9.0.70 SR7

Is this a regression from previous behavior?

Unknown

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 15 (possibly also earlier)

Did you find any workaround?

No

Relevant log output

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-controls-collectionviewCollectionView, CarouselView, IndicatorViewp/1Work that is important, and has been scheduled for release in this or an upcoming sprintpartner/syncfusionIssues / PR's with Syncfusion collaborationplatform/androids/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions