目录

Configuring a Component Without a Primary Button

Use Case

The function of configuring a component without a primary button is available since version 6.0.0(20).

The HdsActionBar (action bar) component supports the multi-button style. If your app requires multiple buttons without any primary button or the effect to expand or collapse buttons, you can just configure the settings for the buttons on the left and right.

Development Procedure

  1. Import required modules.

    import { HdsActionBar, ActionBarButton } from '@kit.UIDesignKit'
  2. Create startButtons (array of the buttons on the left of the primary button) and endButtons (array of the buttons on the right of the primary button), without any primary button or the effect to expand or collapse buttons.

    @Entry
    @ComponentV2
    struct Index {
    
      build() {
        Column() {
          HdsActionBar({
            startButtons: [new ActionBarButton({
              baseIcon: $r('sys.symbol.stopwatch_fill')
            }), new ActionBarButton({
              baseIcon: $r('sys.symbol.stopwatch_fill')
            })],
            endButtons: [new ActionBarButton({
              baseIcon: $r('sys.symbol.mic_fill')
            })]
          })
        }
        .width('100%')
        .height('100%')
        .backgroundColor(0xF1F3F5)
        .justifyContent(FlexAlign.Center)
        .alignItems(HorizontalAlign.Center)
      }
    }