Blank:空白填充组件
在容器主轴方向上,具有自动填充容器空余部分
的能力。仅当父组件为Row
/Column
/Flex
时生效。
Blank('160').color(Color.Yellow) // 设置最小宽度为160
@Entry
@Component
struct Blank_page {
@State message: string = 'Hello World';
build() {
Column({ space: 20 }) {
Row() {
Text('Bluetooth')
Blank().color(Color.Yellow) // 宽度为0
Toggle({ type: ToggleType.Switch })
}.backgroundColor(Color.Pink)
Row() {
Text('Bluetooth')
Blank().color(Color.Yellow)
Toggle({ type: ToggleType.Switch }) // 宽度自动拓展
}.backgroundColor(Color.Pink).width('100%')
Row() {
Text('Bluetooth')
Blank('160').color(Color.Yellow) // 宽度设置为固定值160
Toggle({ type: ToggleType.Switch })
}.backgroundColor(Color.Brown)
}.backgroundColor(Color.Grey).width('100%')
}
}