harmony 鸿蒙Stack

  • 2022-08-09
  • 浏览 (757)

Stack

The <Stack> component provides a stack container where child components are successively stacked and the latter one overwrites the previous one.

NOTE

This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.

Child Components

Supported

APIs

Stack(value?: { alignContent?: Alignment })

Since API version 9, this API is supported in ArkTS widgets.

Parameters

Name Type Mandatory Description
alignContent Alignment No Alignment of child components in the container.
Default value: Alignment.Center

Attributes

In addition to the universal attributes, the following attributes are supported.

Name Type Description
alignContent Alignment Alignment of child components in the container.
Default value: Alignment.Center
Since API version 9, this API is supported in ArkTS widgets.
NOTE
When both this attribute and the universal attribute align are set, whichever is set last takes effect.

Example

// xxx.ets
@Entry
@Component
struct StackExample {
  build() {
    Stack({ alignContent: Alignment.Bottom }) {
      Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top)
      Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top)
    }.width('100%').height(150).margin({ top: 5 })
  }
}

en-us_image_0000001219982699

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkTS-based Declarative Development Paradigm

harmony 鸿蒙@ohos.multimedia.avCastPicker (AVCastPicker)

harmony 鸿蒙Property Animation

harmony 鸿蒙Enums

harmony 鸿蒙Blank

harmony 鸿蒙Button

harmony 鸿蒙CalendarPicker

harmony 鸿蒙Checkbox

harmony 鸿蒙CheckboxGroup

harmony 鸿蒙DataPanel

0  赞