@Entry
@Component
struct layoutWeightExample {
build() {
Column() {
Text(
'1:2:3'
).width(
'100%'
)
Row() {
Column() {
Text(
'layoutWeight(1)'
)
.textAlign(TextAlign.Center)
}.layoutWeight(
1
).backgroundColor(
0xF5DEB3
).height(
'100%'
)
Column() {
Text(
'layoutWeight(2)'
)
.textAlign(TextAlign.Center)
}.layoutWeight(
2
).backgroundColor(
0xD2B48C
).height(
'100%'
)
Column() {
Text(
'layoutWeight(3)'
)
.textAlign(TextAlign.Center)
}.layoutWeight(
3
).backgroundColor(
0xF5DEB3
).height(
'100%'
)
}.backgroundColor(
0xffd306
).height(
'30%'
)
Text(
'2:5:3'
).width(
'100%'
)
Row() {
Column() {
Text(
'layoutWeight(2)'
)
.textAlign(TextAlign.Center)
}.layoutWeight(
2
).backgroundColor(
0xF5DEB3
).height(
'100%'
)
Column() {
Text(
'layoutWeight(5)'
)
.textAlign(TextAlign.Center)
}.layoutWeight(
5
).backgroundColor(
0xD2B48C
).height(
'100%'
)
Column() {
Text(
'layoutWeight(3)'
)
.textAlign(TextAlign.Center)
}.layoutWeight(
3
).backgroundColor(
0xF5DEB3
).height(
'100%'
)
}.backgroundColor(
0xffd306
).height(
'30%'
)
}
}
}