summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls/GalleryPages/RelativeLayoutGallery.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Controls/GalleryPages/RelativeLayoutGallery.cs')
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/RelativeLayoutGallery.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls/GalleryPages/RelativeLayoutGallery.cs b/Xamarin.Forms.Controls/GalleryPages/RelativeLayoutGallery.cs
new file mode 100644
index 00000000..1feaafe6
--- /dev/null
+++ b/Xamarin.Forms.Controls/GalleryPages/RelativeLayoutGallery.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Controls
+{
+ public class RelativeLayoutGallery : ContentPage
+ {
+ public RelativeLayoutGallery()
+ {
+ var layout = new RelativeLayout ();
+
+ var box1 = new ContentView {
+ BackgroundColor = Color.Gray,
+ Content = new Label {
+ Text = "0"
+ }
+ };
+
+ double padding = 10;
+ layout.Children.Add (box1, () => new Rectangle (((layout.Width + padding) % 60) / 2, padding, 50, 50));
+
+ var last = box1;
+ for (int i = 0; i < 200; i++) {
+ var relativeTo = last; // local copy
+ var box = new ContentView {
+ BackgroundColor = Color.Gray,
+ Content = new Label {
+ Text = (i+1).ToString ()
+ }
+ };
+
+ Func<View, bool> pastBounds = view => relativeTo.Bounds.Right + padding + relativeTo.Width > layout.Width;
+ layout.Children.Add (box, () => new Rectangle (pastBounds (relativeTo) ? box1.X : relativeTo.Bounds.Right + padding,
+ pastBounds (relativeTo) ? relativeTo.Bounds.Bottom + padding : relativeTo.Y,
+ relativeTo.Width,
+ relativeTo.Height));
+
+ last = box;
+ }
+
+ Content = new ScrollView {Content = layout, Padding = new Thickness(50)};
+ }
+ }
+}