鸿蒙(HarmonyOS)项目方舟框架(ArkUI)之Divider组件

鸿蒙(HarmonyOS)项目方舟框架(ArkUI)之Divider组件

一、操作环境

操作系统:  Windows 10 专业版、IDE:DevEco Studio 3.1、SDK:HarmonyOS 3.1+

二、Divider组件

提供分隔器组件,分隔不同内容块/内容元素。

子组件

接口

Divider()

从API version 9开始,该接口支持在ArkTS卡片中使用。

属性

除支持通用属性外,还支持以下属性:

名称

参数类型

描述

vertical

boolean

使用水平分割线还是垂直分割线。false:水平分割线;true:垂直分割线。

默认值:false

从API version 9开始,该接口支持在ArkTS卡片中使用。

color

ResourceColor

分割线颜色。

默认值:'#33182431'

从API version 9开始,该接口支持在ArkTS卡片中使用。

strokeWidth

number | string

分割线宽度。

默认值:1

单位:vp

从API version 9开始,该接口支持在ArkTS卡片中使用。

说明:

分割线的宽度不支持百分比设置。优先级低于通用属性height,超过通用属性设置大小时,按照通用属性进行裁切。

lineCap

LineCapStyle

分割线的端点样式。

默认值:LineCapStyle.Butt

从API version 9开始,该接口支持在ArkTS卡片中使用。

示例

代码
// xxx.ets
@Entry
@Component
struct DividerExample {
  build() {
    Column() {
      // 使用横向分割线场景
      Text('Horizontal divider').fontSize(9).fontColor(0xCCCCCC)
      List() {
        ForEach([1, 2, 3], (item) => {
          ListItem() {
            Text('list' + item).width('100%').fontSize(14).fontColor('#182431').textAlign(TextAlign.Start)
          }.width(244).height(48)
        }, item => item.toString())
      }.padding({ left: 24, bottom: 8 })

      Divider().strokeWidth(8).color('#F1F3F5')
      List() {
        ForEach([4, 5], (item) => {
          ListItem() {
            Text('list' + item).width('100%').fontSize(14).fontColor('#182431').textAlign(TextAlign.Start)
          }.width(244).height(48)
        }, item => item.toString())
      }.padding({ left: 24, top: 8 })

      // 使用纵向分割线场景
      Text('Vertical divider').fontSize(9).fontColor(0xCCCCCC)
      Column() {
        Column() {
          Row().width(288).height(64).backgroundColor('#30C9F0').opacity(0.3)
          Row() {
            Button('Button')
              .width(136)
              .height(22)
              .fontSize(16)
              .fontColor('#007DFF')
              .fontWeight(500)
              .backgroundColor(Color.Transparent)
            Divider().vertical(true).height(22).color('#182431').opacity(0.6).margin({ left: 8, right: 8 })
            Button('Button')
              .width(136)
              .height(22)
              .fontSize(16)
              .fontColor('#007DFF')
              .fontWeight(500)
              .backgroundColor(Color.Transparent)
          }.margin({ top: 17 })
        }
        .width(336)
        .height(152)
        .backgroundColor('#FFFFFF')
        .borderRadius(24)
        .padding(24)
      }
      .width('100%')
      .height(168)
      .backgroundColor('#F1F3F5')
      .justifyContent(FlexAlign.Center)
      .margin({ top: 8 })
    }.width('100%').padding({ top: 24 })
  }
}
图例

你有时间常去我家看看我在这里谢谢你啦...

我家地址:亚丁号

最后送大家一首诗:

山高路远坑深,
大军纵横驰奔,

谁敢横刀立马?
惟有点赞加关注大军。

最近更新

  1. TCP协议是安全的吗?

    2024-02-13 13:36:01       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-13 13:36:01       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-13 13:36:01       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-13 13:36:01       18 阅读

热门阅读

  1. VUE SEO 几种方案经典面试题

    2024-02-13 13:36:01       28 阅读
  2. 如何控制系统安全 或 控制流氓软件

    2024-02-13 13:36:01       26 阅读
  3. Python开发者转型Go开发

    2024-02-13 13:36:01       23 阅读
  4. SpringBoot中全局异常处理

    2024-02-13 13:36:01       28 阅读
  5. 跟我学C++中级篇——函数模板的匹配

    2024-02-13 13:36:01       32 阅读
  6. uniapp禁止截屏录屏/投屏功能(adb投放失效)

    2024-02-13 13:36:01       28 阅读
  7. XGboost和lightGBM算法对比

    2024-02-13 13:36:01       24 阅读
  8. Python 中的断点类型详解

    2024-02-13 13:36:01       29 阅读