@Entry @Component struct Index { @State message: string = '啥地方'; build() { Column({space:15}) { Image($r('app.media.airplane_fill')) .width(200) .fillColor(Color.Red) } } }
@Entry @Component struct Index { @State message: string = '啥地方'; build() { Column(){ Image($r('app.media.startIcon')) .width(100) Text('大王代码') .fontWeight(700) .margin({ top:10, bottom:40 }) Button('qq') .width('100%') .margin({ bottom:10 }) Button('weix') .width('100%') .backgroundColor('#ddd') .fontColor('#000') } .width('100%') .padding(20) } }
@Entry @Component struct Index { @State message: string = '啥地方'; build() { Column(){ Text('代码哥') .fontColor(Color.Red) .padding(5) .border({ width:1, color:Color.Blue, style:BorderStyle.Dashed }) } .padding(20) } }
Text('但便可') .padding(5) .border({ width:{left:1,right:2}, color:{left:Color.Blue,right:Color.Orange}, style:{left:BorderStyle.Dashed, right:BorderStyle.Dotted} } )
@Entry @Component struct Index { @State message: string = '啥地方'; build() { Column(){ Text('但便可') .padding(10) .backgroundColor(Color.Green) .borderRadius({ topLeft:10, }) } .padding(20) } }
像素点:px实际物理像素。vp虚拟像素
@Entry @Component struct Index { @State message: string = '啥地方'; build() { Column(){ Text() .width(300) .height(150) .backgroundColor(Color.Green) .backgroundImage($r('app.media.startIcon')) .backgroundImageSize(ImageSize.Contain) } }
@Entry @Component struct Index { @State message: string = '啥地方'; build() { Column() { Text() .width(200) .height(100) .backgroundColor(Color.Pink) Text() .width(200) .height(100) .backgroundColor(Color.Pink) .margin(5) Text() .width(200) .height(100) .backgroundColor(Color.Pink) } .width('100%') .height('100%') .justifyContent(FlexAlign.Center) } }
@Entry @Component struct Index { @State message: string = '啥地方'; build() { Row() { Text() .width(60) .height(100) .backgroundColor(Color.Pink) Text() .width(60) .height(100) .backgroundColor(Color.Pink) .margin(5) Text() .width(60) .height(100) .backgroundColor(Color.Pink) } .width('100%') .height('100%') .justifyContent(FlexAlign.End) } }
.alignItems(HorizontalAlign.Start)
@Entry @Component struct Index { @State message: string = '啥地方'; build() { Column() { Row(){ Column(){ Text('三一扫') .fontSize(30) Text('要哟|幺幺出大将来来吗') } .alignItems(HorizontalAlign.Start) Row(){ Image($r('app.media.foreground')) .width(70) .backgroundColor(Color.Brown) } } .justifyContent(FlexAlign.SpaceBetween) .padding({left:15,right:15}) .width('100%') .height(80) .backgroundColor(Color.Gray) .borderRadius(5) } .padding(5) .width('100%') .height('100%') //.justifyContent(FlexAlign.Center) } }
flex