blob: 1feaafe69a7bf92ae11558325a7d3aef0ea5a647 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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)};
}
}
}
|