官方文档:位置设置
目录标题
align:子元素的对齐方式
@Entry
@Component
struct Loc_align {
@State message: string = 'Hello World';
build() {
Column() {
Stack() {Text('TopStart')}.width('100%').height(50).backgroundColor(Color.Pink).align(Alignment.TopStart)
Stack() {Text('Top')}.width('100%').height(50).backgroundColor(Color.Orange).align(Alignment.Top)
Stack() {Text('TopEnd')}.width('100%').height(50).backgroundColor(Color.Pink).align(Alignment.TopEnd)
Stack() {Text('Start')}.width('100%').height(50).backgroundColor(Color.Orange).align(Alignment.Start)
Stack() {Text('Center')}.width('100%').height(50).backgroundColor(Color.Pink).align(Alignment.Center)
Stack() {Text('End')}.width('100%').height(50).backgroundColor(Color.Orange).align(Alignment.End)
Stack() {Text('BottomStart')}.width('100%').height(50).backgroundColor(Color.Pink).align(Alignment.BottomStart)
Stack() {Text('Bottom')}.width('100%').height(50).backgroundColor(Color.Orange).align(Alignment.Bottom)
Stack() {Text('BottomEnd')}.width('100%').height(50).backgroundColor(Color.Pink).align(Alignment.BottomEnd)
}.height('100%')
}
}