Fix sizes of controls

This commit is contained in:
Frank A. Krueger 2018-04-15 19:06:31 -07:00
parent c401f4e4a4
commit f309cb9247
No known key found for this signature in database
GPG Key ID: 0471C67474FFE664
5 changed files with 37 additions and 5 deletions

View File

@ -15,7 +15,7 @@ namespace Ooui.Forms.Renderers
public override SizeRequest GetDesiredSize (double widthConstraint, double heightConstraint)
{
var size = Element.Text.MeasureSize (Element.FontFamily, Element.FontSize, Element.FontAttributes, widthConstraint, heightConstraint);
size = new Size (size.Width + 2 * Element.FontSize, size.Height + Element.FontSize);
size = new Size (size.Width + 32, size.Height + 16);
return new SizeRequest (size, size);
}

View File

@ -14,7 +14,7 @@ namespace Ooui.Forms.Renderers
public override SizeRequest GetDesiredSize (double widthConstraint, double heightConstraint)
{
var size = "00/00/0000".MeasureSize ("", 16.0, FontAttributes.None, widthConstraint, heightConstraint);
size = new Size (size.Width, size.Height);
size = new Size (size.Width + 32, size.Height + 16);
return new SizeRequest (size, size);
}

View File

@ -25,8 +25,9 @@ namespace Ooui.Forms.Renderers
text = " ";
}
var size = text.MeasureSize (Element.FontFamily, Element.FontSize, Element.FontAttributes, widthConstraint, heightConstraint);
var vpadding = Element.FontSize;
size = new Size (size.Width, size.Height + vpadding);
var vpadding = 16;
var hpadding = 32;
size = new Size (size.Width + hpadding, size.Height + vpadding);
return new SizeRequest (size, size);
}

View File

@ -15,7 +15,7 @@ namespace Ooui.Forms.Renderers
{
var fontSize = 16.0;
var size = "00:00:00".MeasureSize(string.Empty, fontSize, FontAttributes.None, widthConstraint, heightConstraint);
size = new Size(size.Width, size.Height + fontSize);
size = new Size(size.Width + 32, size.Height + 16);
return new SizeRequest(size, size);
}

View File

@ -23,6 +23,37 @@ namespace Samples
row1.Children.Add (new Label { Text = longText, FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.End });
rows.Children.Add (row1);
var row2 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.Azure };
row2.Children.Add (new Entry { Text = shortText, FontSize = 8, VerticalOptions = LayoutOptions.Center });
row2.Children.Add (new Entry { Text = shortText, FontSize = 16, VerticalOptions = LayoutOptions.Center });
row2.Children.Add (new Entry { Text = shortText, FontSize = 32, VerticalOptions = LayoutOptions.Center });
row2.Children.Add (new Button { Text = shortText, FontSize = 32, VerticalOptions = LayoutOptions.Center });
rows.Children.Add (row2);
var row3 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.GhostWhite };
row3.Children.Add (new Entry { Text = shortText, FontSize = 8, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold });
row3.Children.Add (new Entry { Text = shortText, FontSize = 16, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold });
row3.Children.Add (new Entry { Text = shortText, FontSize = 32, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold });
row3.Children.Add (new Button { Text = shortText, FontSize = 32, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold });
rows.Children.Add (row3);
var row4 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.Azure };
row4.Children.Add (new Button { Text = shortText, FontSize = 8, VerticalOptions = LayoutOptions.Center });
row4.Children.Add (new Button { Text = shortText, FontSize = 16, VerticalOptions = LayoutOptions.Center });
row4.Children.Add (new Button { Text = shortText, FontSize = 32, VerticalOptions = LayoutOptions.Center });
rows.Children.Add (row4);
var row5 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.GhostWhite };
row5.Children.Add (new Button { Text = shortText, FontSize = 8, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold });
row5.Children.Add (new Button { Text = shortText, FontSize = 16, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold });
row5.Children.Add (new Button { Text = shortText, FontSize = 32, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold });
rows.Children.Add (row5);
var row6 = new StackLayout { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.GhostWhite };
row6.Children.Add (new DatePicker { VerticalOptions = LayoutOptions.Center });
row6.Children.Add (new TimePicker { VerticalOptions = LayoutOptions.Center });
rows.Children.Add (row6);
var page = new ContentPage
{
Content = rows