XCarousel.Touch | XCarousel.Droid | .Touch.Sample | .Droid.Sample |
---|---|---|---|
On client projects install the nuget XCarouselPicker () and then follow the steps based on platform:
- Add a new XCarouselView inside your Main layout file:
<XCarousel.Droid.Views.XCarouselView
android:id="@+id/picker"
android:background="@android:color/transparent"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</XCarousel.Droid.Views.XCarouselView>
- In your Activity you'll need to assign a Collection to this view:
var picker = FindViewById<XCarouselView>(Resource.Id.picker);
var products = new List<PickerItem>();
products.Add(new DrawableItem(Resource.Drawable.CoffeeAsset));
products.Add(new DrawableItem(Resource.Drawable.CoffeeAsset));
products.Add(new DrawableItem(Resource.Drawable.CoffeeAsset));
products.Add(new DrawableItem(Resource.Drawable.CoffeeAsset));
products.Add(new DrawableItem(Resource.Drawable.CoffeeAsset));
products.Add(new DrawableItem(Resource.Drawable.CoffeeAsset));
products.Add(new DrawableItem(Resource.Drawable.CoffeeAsset));
picker.Items = products;
- And for the FadeEffect to take place you'll need to assign the desired FadeColor:
picker.FadeColor = "#ecf0f1";
Note that this UICollectionView customization was designed to work with one row and horizontal scrolling. If you have a different case, create a pull request to see if we can addapt the component to more general needs.
-
Add a new UICollectionView to your view. Within Widget properties, select "XCarouselView" as you CollectionViewType.
-
Create your UICollectionViewCell. There is no known restriction on what can be in here.
-
Create your UICollectionViewDataSource.
-
Wire everything together:
customCollectionView.RegisterNibForCell(CustomCollectionViewCell.Nib, CustomCollectionViewCell.Key);
customCollectionView.DataSource = new CustomDataSource();
Now your project should have a UICollectionView that resembles the behaviour from the Preview gif.
- The current state of the component works properly only with one image within the element of the XCarouselPicker. If you have a different scenario, please do create an issue and we'll see how we can addapt the component to it.