咨询描述:ArkUI 多 stack 嵌套,外层 stack 是否继承内层 stack 的 UI 样式
咨询场景描述:Demo:
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
Row() {
Text(this.message)
.fontColor(Color.Red)
}
.width('100%')
.backgroundColor(Color.Pink)
}
}@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
Stack() {
T1().height(20).width(20)
}.width("100%").height("100%")
}
}
@Component
struct T1 {
build() {
Stack() {
Stack()
.height(100).width(100).backgroundColor(Color.Black)
}
}
}
@Component
struct T2 {
build() {
Stack()
.height(100).width(100).backgroundColor(Color.Black)
}
}
期望 T1 组件和 T2 组件渲染相同,即组件外层 Stack 继承内层 Stack 样式。想详细了解 Stack 堆叠使用原理。
S1(父)、S2(子)、S3(孙) 依次堆叠
S2 现在有三种状态:不写、固定、100%
不写:S2 宽高跟着 S1、S3 的最小宽高
固定:S2 跟着自己(S2)
100%:S2 跟着父组件(S1)