Rectangle
Basic example
View.Rectangle(
fill = View.SolidColorBrush(Color.Black),
stroke = View.SolidColorBrush(Color.Orange),
strokeThickness = 5.,
width = 150.,
height = 50.
)
Basic example with styling
View.Rectangle(
horizontalOptions = style.Position,
verticalOptions = style.Position,
backgroundColor = style.ViewColor,
margin = style.Thickness,
fill = View.SolidColorBrush(Color.Black),
stroke = View.SolidColorBrush(Color.Orange),
strokeThickness = 5.,
width = 150.,
height = 50.
)
See also:
More examples
Rectangle
can be used to draw rectangles and squares.
// Filled rectangle
View.Rectangle(
fill = View.SolidColorBrush(Color.Red),
width = 150.,
height = 50.,
horizontalOptions = LayoutOptions.Start
)
// Square
View.Rectangle(
stroke = View.SolidColorBrush(Color.Red),
strokeThickness = 4.,
width = 150.,
height = 150.,
horizontalOptions = LayoutOptions.Start
)
// Rectangle with stroke
View.Rectangle(
stroke = View.SolidColorBrush(Color.Red),
strokeThickness = 4.,
width = 150.,
height = 50.,
horizontalOptions = LayoutOptions.Start
)
// Filled rectangle with stroke
View.Rectangle(
fill = View.SolidColorBrush(Color.DarkBlue),
stroke = View.SolidColorBrush(Color.Red),
strokeThickness = 4.,
width = 150.,
height = 50.,
horizontalOptions = LayoutOptions.Start
)
// Filled rectangle with dashed stroke
View.Rectangle(
fill = View.SolidColorBrush(Color.DarkBlue),
stroke = View.SolidColorBrush(Color.Red),
strokeThickness = 4.,
strokeDashArray = [ 1.; 1. ],
strokeDashOffset = 6.,
width = 150.,
height = 50.,
horizontalOptions = LayoutOptions.Start
)
// Rectangle with rounded corners
View.Rectangle(
fill = View.SolidColorBrush(Color.Blue),
stroke = View.SolidColorBrush(Color.Black),
strokeThickness = 3.,
radiusX = 50.,
radiusY = 10.,
width = 200.,
height = 100.,
horizontalOptions = LayoutOptions.Start
)