In this recipe, we will learn how to customize the display of the collection view.
In this recipe, we will work on the CollectionViewApp
project we created in the Displaying data in a grid recipe. Open the project in Xamarin Studio.
Perform the following steps:
In the
ViewDidLoad
method of the controller, add the following code:UICollectionViewFlowLayout flowLayout = new UICollectionViewFlowLayout(); flowLayout.MinimumLineSpacing = 20f; flowLayout.MinimumInteritemSpacing = 4f; flowLayout.SectionInset = new UIEdgeInset(4f, 4f, 4f, 4f); flowLayout.ItemSize = new SizeF(20f, 20f); this.collectionView.CollectionViewLayout = flowLayout;
Compile and run the app on the simulator. The result should be similar to the one shown in the following screenshot: