I am trying to create a page with absolute layout in code for speed and easy of layout as I plan to position a lot of labels. The page is supposed to show sections, e.g. "Section1" with a background color at the left edge of the screen with 90 degree rotated text. Whatever I try I either cannot get the size correct or/and the position correct.
Sample Code below:
public class DemoPage : ContentPage
AbsoluteLayout absoluteLayout = new AbsoluteLayout();
Label label1 = new Label(); label1.Text = "label1"; label1.BackgroundColor = Color.Green; Label label2 = new Label(); label2.Text = "label2"; label2.BackgroundColor = Color.Red; label2.Rotation = 90; Label label3 = new Label(); label3.Text = "label3"; label3.BackgroundColor = Color.Yellow; label3.Rotation = 90; // correct absoluteLayout.Children.Add(label1, new Rectangle(0, 0, 100, 50)); // goal: a bar with 90 degree rotated text at the edge of the screen // should be 50 width and 100 height // but is 100 width and 50 height and positioned about 50 pixel too far down absoluteLayout.Children.Add(label2, new Rectangle(0, 110, 50, 100)); // should be 100 width and 50 height // but is 50 width and 100 height and positioned about 25 pixels too far right absoluteLayout.Children.Add(label3, new Rectangle(0, 220, 100, 50)); this.Content = absoluteLayout; } }
And the result shown in the attached image.
Maybe there is something like a rotation point I have to define, but I have not found it.
Can anyone help? This is probably something easy I miss.