HarmonyOS NEXT应用元服务开发多维嵌套场景

鸿蒙时代
发布于 2024-10-14 10:53
浏览
0收藏

如果应用展示的是多维信息,还可能出现“嵌套组”的情况。在嵌套组中,应避免两个可获焦对象的功能或朗读内容产生重复。比如下图的天气卡片,时间和地点信息获取到焦点时,都是朗读的时间信息;不同焦点的重复朗读会额外增减用户的操作步骤,焦点控制杂乱,这些对同一个信息结构的完整描述应该统一标注在这几个子控件的父控件上。
HarmonyOS NEXT应用元服务开发多维嵌套场景-鸿蒙开发者社区

@Component
export struct Rule_2_1_4 {
  title: string = 'Rule 2.1.4'

  build() {
    NavDestination() {
      Column() {
        Text('Incorrect behavior:') // 播报 "Time Group 12:05 Beijing" + "12:05" + "Beijing".
                                    //继续下滑焦点可聚焦至子控件文本重复了两次。这是不正确的。
          .width('100%')
          .fontSize(12)
          .fontColor(Color.Black)
          .margin({bottom: 12})
        Row(){
          Text("12:05") // time information
            .fontSize(32)
            .fontColor(Color.Red)
            .fontWeight(FontWeight.Bold)
            .textAlign(TextAlign.Center)
            .margin({right: 20})

          Text("Beijing") // location information
            .fontSize(20)
            .fontColor(Color.Green)
            .fontWeight(FontWeight.Bold)
            .textAlign(TextAlign.Center)
        }
        .accessibilityText("Time Group") // 时间信息、位置信息和此可访问性文本在获得焦点时被朗读。
                                         // 带有时间信息的文本组件可聚焦并朗读
                                         // 具有位置信息的文本组件可聚焦并朗读
        .height(50)
        .margin({bottom: 150})

        Text('Correct behavior:') // 只朗读 "07:05 Moscow" ,不重复文本。是正确的。
          .width('100%')
          .fontSize(12)
          .fontColor(Color.Black)
          .margin({bottom: 12})
        Row(){
          Text("07:05") // time information
            .fontSize(32)
            .fontColor(Color.Red)
            .fontWeight(FontWeight.Bold)
            .textAlign(TextAlign.Center)
            .margin({right: 20})

          Text("Moscow") // location information
            .fontSize(20)
            .fontColor(Color.Green)
            .fontWeight(FontWeight.Bold)
            .textAlign(TextAlign.Center)
        }
        .height(50)
        .accessibilityGroup(true) // 获取焦点时朗读时间和位置信息。
                                  // 带有时间信息的文本组件无法聚焦和朗读
                                  //具有位置信息的文本组件无法获得焦点并朗读
      }
      .alignItems(HorizontalAlign.Start)
      .padding(10)
    }
    .title(this.title)
  }
}

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.

本文主要引用官方文档材料基API 12 Release

分类
收藏
回复
举报


回复
    相关推荐