跳转到主要内容

xaml 布局控件

 StackLayout

属性名 说明
Orientation 布局方向(Vertical/Horizontal)
Spacing 子元素间距
Padding 内边距
Margin 外边距
HorizontalOptions 水平对齐方式
VerticalOptions 垂直对齐方式
BackgroundColor 背景色

Grid

属性名 说明
RowDefinitions 行定义(高度)
ColumnDefinitions 列定义(宽度)
Padding 内边距
Margin 外边距
RowSpacing 行间距
ColumnSpacing 列间距
BackgroundColor 背景色
子元素特有属性:

Grid.Row:所在行
Grid.Column:所在列
Grid.RowSpan:跨行数
Grid.ColumnSpan:跨列数

FlexLayout

属性名 说明
Direction 主轴方向(Row/Column)
Wrap 是否换行(NoWrap/Wrap/Reverse)
JustifyContent 主轴对齐方式
AlignItems 交叉轴对齐方式
AlignContent 多行对齐方式
Padding 内边距
Margin 外边距
BackgroundColor 背景色
子元素特有属性:

FlexLayout.Order:排序权重
FlexLayout.Grow:放大比例
FlexLayout.Shrink:缩小比例
FlexLayout.Basis:主轴初始大小
FlexLayout.AlignSelf:单独对齐方式

AbsoluteLayout

属性名 说明
Padding 内边距
Margin 外边距
BackgroundColor 背景色
子元素特有属性:

AbsoluteLayout.LayoutBounds:位置和尺寸(如 "x, y, width, height")
AbsoluteLayout.LayoutFlags:尺寸和位置的解释方式(All/None/WidthProportional/HeightProportional等)

VerticalStackLayout / HorizontalStackLayout

性能更优的垂直/水平堆叠布局

属性名 说明
Spacing 子元素间距
Padding 内边距
Margin 外边距
HorizontalOptions 水平对齐方式
VerticalOptions 垂直对齐方式
BackgroundColor 背景色

ContentView

属性名 说明
Content 内部内容
Padding 内边距
Margin 外边距
BackgroundColor 背景色

通用布局属性

HorizontalOptions、VerticalOptions:对齐方式(Start、Center、End、Fill)
Margin、Padding:外边距、内边距
BackgroundColor:背景色
IsVisible、IsEnabled、Opacity:可见性、可用性、透明度
WidthRequest、HeightRequest:宽高请求