chinese直男口爆体育生外卖, 99久久er热在这里只有精品99, 又色又爽又黄18禁美女裸身无遮挡, gogogo高清免费观看日本电视,私密按摩师高清版在线,人妻视频毛茸茸,91论坛 兴趣闲谈,欧美 亚洲 精品 8区,国产精品久久久久精品免费

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內(nèi)不再提示

鴻蒙ArkTS聲明式開發(fā):跨平臺支持列表【布局約束】 通用屬性

jf_46214456 ? 來源:jf_46214456 ? 作者:jf_46214456 ? 2024-05-30 09:35 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

布局約束

通過組件的寬高比和顯示優(yōu)先級約束組件顯示效果。

說明:
開發(fā)前請熟悉鴻蒙開發(fā)指導文檔 :[gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md]
從API Version 7開始支持。后續(xù)版本如有新增內(nèi)容,則采用上角標單獨標記該內(nèi)容的起始版本。

屬性

名稱參數(shù)說明描述
aspectRationumber指定當前組件的寬高比,aspectRatio = width/height。 從API version 9開始,該接口支持在ArkTS卡片中使用。 API version 9及以前,默認值為:1.0。 API version 10:無默認值。**說明:**該屬性在不設置值或者設置非法值時不生效。 例如,Row只設置寬度且沒有子組件,aspectRatio不設置值或者設置成負數(shù)時,此時Row高度為0。
displayPrioritynumber設置當前組件在布局容器中顯示的優(yōu)先級,當父容器空間不足時,低優(yōu)先級的組件會被隱藏。 小數(shù)點后的數(shù)字不作優(yōu)先級區(qū)分,即區(qū)間為[x, x + 1)內(nèi)的數(shù)字視為相同優(yōu)先級。例如:1.0與1.9為同一優(yōu)先級。 從API version 9開始,該接口支持在ArkTS卡片中使用。**說明:**僅在Row/Column/Flex(單行)容器組件中生效。

示例

示例1

// xxx.ets
@Entry
@Component
struct AspectRatioExample {
  private children: string[] = ['1', '2', '3', '4', '5', '6']

  build() {
    Column({ space: 20 }) {
      Text('using container: row').fontSize(14).fontColor(0xCCCCCC).width('100%')
      Row({ space: 10 }) {
        ForEach(this.children, (item:string) = > {
          // 組件寬度 = 組件高度*1.5 = 90
          Text(item)
            .backgroundColor(0xbbb2cb)
            .fontSize(20)
            .aspectRatio(1.5)
            .height(60)
          // 組件高度 = 組件寬度/1.5 = 60/1.5 = 40
          Text(item)
            .backgroundColor(0xbbb2cb)
            .fontSize(20)
            .aspectRatio(1.5)
            .width(60)
        }, (item:string) = > item)
      }
      .size({ width: "100%", height: 100 })
      .backgroundColor(0xd2cab3)
      .clip(true)

      // grid子元素width/height=3/2
      Text('using container: grid').fontSize(14).fontColor(0xCCCCCC).width('100%')
      Grid() {
        ForEach(this.children, (item:string) = > {
          GridItem() {
            Text(item)
              .backgroundColor(0xbbb2cb)
              .fontSize(40)
              .width('100%')
              .aspectRatio(1.5)
          }
        }, (item:string) = > item)
      }
      .columnsTemplate('1fr 1fr 1fr')
      .columnsGap(10)
      .rowsGap(10)
      .size({ width: "100%", height: 165 })
      .backgroundColor(0xd2cab3)
    }.padding(10)
  }
}

圖1 豎屏顯示
zh-cn_image_0000001219744205

圖2 橫屏顯示
zh-cn_image_0000001174264382

示例2

class ContainerInfo {
  label: string = '';
  size: string = '';
}

class ChildInfo {
  text: string = '';
  priority: number = 0;
}

@Entry
@Component
struct DisplayPriorityExample {
  // 顯示容器大小
  private container: ContainerInfo[] = [
    { label: 'Big container', size: '90%' },
    { label: 'Middle container', size: '50%' },
    { label: 'Small container', size: '30%' }
  ]
  private children: ChildInfo[] = [
    { text: '1n(priority:2)', priority: 2 },
    { text: '2n(priority:1)', priority: 1 },
    { text: '3n(priority:3)', priority: 3 },
    { text: '4n(priority:1)', priority: 1 },
    { text: '5n(priority:2)', priority: 2 }
  ]
  @State currentIndex: number = 0;

  build() {
    Column({ space: 10 }) {
      // 切換父級容器大小
      Button(this.container[this.currentIndex].label).backgroundColor(0x317aff)
        .onClick(() = > {
          this.currentIndex = (this.currentIndex + 1) % this.container.length;
        })
      // 通過變量設置Flex父容器寬度
      Flex({ justifyContent: FlexAlign.SpaceBetween }) {
        ForEach(this.children, (item:ChildInfo) = > {
          // 使用displayPriority給子組件綁定顯示優(yōu)先級
          Text(item.text)
            .width(120)
            .height(60)
            .fontSize(24)
            .textAlign(TextAlign.Center)
            .backgroundColor(0xbbb2cb)
            .displayPriority(item.priority)
        }, (item:ChildInfo) = > item.text)
      }
      .width(this.container[this.currentIndex].size)
      .backgroundColor(0xd2cab3)
    }.width("100%").margin({ top: 50 })
  }
}

`HarmonyOSOpenHarmony鴻蒙文檔籽料:mau123789是v直接拿`

搜狗高速瀏覽器截圖20240326151450.png

橫屏顯示

zh-cn_image_0000001219662667

審核編輯 黃宇

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學習之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • 鴻蒙
    +關注

    關注

    60

    文章

    2736

    瀏覽量

    45015
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評論

    相關推薦
    熱點推薦

    鴻蒙ArkTS聲明開發(fā)平臺支持列表【位置設置】 通用屬性

    設置組件的對齊方式、布局方向和顯示位置。
    的頭像 發(fā)表于 05-31 11:17 ?2152次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>聲明</b><b class='flag-5'>式</b><b class='flag-5'>開發(fā)</b>:<b class='flag-5'>跨</b><b class='flag-5'>平臺</b><b class='flag-5'>支持</b><b class='flag-5'>列表</b>【位置設置】 <b class='flag-5'>通用</b><b class='flag-5'>屬性</b>

    鴻蒙語言ArkTS(更好的生產(chǎn)力與性能)

    ArkTS鴻蒙生態(tài)的應用開發(fā)語言 ArkTS提供了聲明UI范式、狀態(tài)管理
    發(fā)表于 02-17 15:56

    HarmonyOS/OpenHarmony應用開發(fā)-ArkTS聲明開發(fā)范式

    基于ArkTS聲明開發(fā)范式的方舟開發(fā)框架是一套開發(fā)極簡、高性能、
    發(fā)表于 01-17 15:09

    鴻蒙ArkTS聲明開發(fā)平臺支持列表【按鍵事件】

    按鍵事件指組件與鍵盤、遙控器等按鍵設備交互時觸發(fā)的事件,適用于所有可獲焦組件,例如Button。對于Text,Image等默認不可獲焦的組件,可以設置focusable屬性為true后使用按鍵事件。
    的頭像 發(fā)表于 05-28 18:12 ?1599次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>聲明</b><b class='flag-5'>式</b><b class='flag-5'>開發(fā)</b>:<b class='flag-5'>跨</b><b class='flag-5'>平臺</b><b class='flag-5'>支持</b><b class='flag-5'>列表</b>【按鍵事件】

    鴻蒙ArkTS聲明開發(fā)平臺支持列表【Flex布局通用屬性

    從API Version 7開始支持。后續(xù)版本如有新增內(nèi)容,則采用上角標單獨標記該內(nèi)容的起始版本。 > - 僅當父組件是 Flex、Column、Row 、GridRow時生效。
    的頭像 發(fā)表于 05-30 14:38 ?1307次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>聲明</b><b class='flag-5'>式</b><b class='flag-5'>開發(fā)</b>:<b class='flag-5'>跨</b><b class='flag-5'>平臺</b><b class='flag-5'>支持</b><b class='flag-5'>列表</b>【Flex<b class='flag-5'>布局</b>】 <b class='flag-5'>通用</b><b class='flag-5'>屬性</b>

    鴻蒙ArkTS聲明開發(fā)平臺支持列表【背景設置】 通用屬性

    從API Version 7開始支持。后續(xù)版本如有新增內(nèi)容,則采用上角標單獨標記該內(nèi)容的起始版本。
    的頭像 發(fā)表于 05-31 15:22 ?1433次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>聲明</b><b class='flag-5'>式</b><b class='flag-5'>開發(fā)</b>:<b class='flag-5'>跨</b><b class='flag-5'>平臺</b><b class='flag-5'>支持</b><b class='flag-5'>列表</b>【背景設置】 <b class='flag-5'>通用</b><b class='flag-5'>屬性</b>

    鴻蒙ArkTS聲明開發(fā)平臺支持列表【顯隱控制】 通用屬性

    控制當前組件顯示或隱藏。注意,即使組件處于隱藏狀態(tài),在頁面刷新時仍存在重新創(chuàng)建過程,因此當對性能有嚴格要求時建議使用[條件渲染]代替。 默認值:Visibility.Visible 從API version 9開始,該接口支持ArkTS卡片中使用。
    的頭像 發(fā)表于 06-03 14:46 ?1272次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>聲明</b><b class='flag-5'>式</b><b class='flag-5'>開發(fā)</b>:<b class='flag-5'>跨</b><b class='flag-5'>平臺</b><b class='flag-5'>支持</b><b class='flag-5'>列表</b>【顯隱控制】 <b class='flag-5'>通用</b><b class='flag-5'>屬性</b>

    鴻蒙ArkTS聲明開發(fā)平臺支持列表【形狀裁剪】 通用屬性

    參數(shù)為相應類型的組件,按指定的形狀對當前組件進行裁剪;參數(shù)為boolean類型時,設置是否按照父容器邊緣輪廓進行裁剪。 默認值:false 從API version 9開始,該接口支持ArkTS卡片中使用。
    的頭像 發(fā)表于 06-04 15:22 ?940次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>聲明</b><b class='flag-5'>式</b><b class='flag-5'>開發(fā)</b>:<b class='flag-5'>跨</b><b class='flag-5'>平臺</b><b class='flag-5'>支持</b><b class='flag-5'>列表</b>【形狀裁剪】 <b class='flag-5'>通用</b><b class='flag-5'>屬性</b>

    鴻蒙ArkTS聲明開發(fā)平臺支持列表【柵格設置】 通用屬性

    默認占用列數(shù),指useSizeType屬性沒有設置對應尺寸的列數(shù)(span)時,占用的柵格列數(shù)。
    的頭像 發(fā)表于 06-05 09:28 ?949次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>聲明</b><b class='flag-5'>式</b><b class='flag-5'>開發(fā)</b>:<b class='flag-5'>跨</b><b class='flag-5'>平臺</b><b class='flag-5'>支持</b><b class='flag-5'>列表</b>【柵格設置】 <b class='flag-5'>通用</b><b class='flag-5'>屬性</b>

    鴻蒙ArkTS聲明開發(fā)平臺支持列表【菜單控制】 通用屬性

    為組件綁定彈出菜單,彈出菜單以垂直列表形式顯示菜單項,可通過長按、點擊或鼠標右鍵觸發(fā)。
    的頭像 發(fā)表于 06-06 09:17 ?1691次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>聲明</b><b class='flag-5'>式</b><b class='flag-5'>開發(fā)</b>:<b class='flag-5'>跨</b><b class='flag-5'>平臺</b><b class='flag-5'>支持</b><b class='flag-5'>列表</b>【菜單控制】 <b class='flag-5'>通用</b><b class='flag-5'>屬性</b>

    鴻蒙ArkTS聲明開發(fā)平臺支持列表【組件標識】 通用屬性

    id為組件的唯一標識,在整個應用內(nèi)唯一。本模塊提供組件標識相關接口,可以獲取指定id組件的屬性,也提供向指定id組件發(fā)送事件的功能。
    的頭像 發(fā)表于 06-06 15:51 ?947次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>聲明</b><b class='flag-5'>式</b><b class='flag-5'>開發(fā)</b>:<b class='flag-5'>跨</b><b class='flag-5'>平臺</b><b class='flag-5'>支持</b><b class='flag-5'>列表</b>【組件標識】 <b class='flag-5'>通用</b><b class='flag-5'>屬性</b>

    鴻蒙ArkTS聲明開發(fā)平臺支持列表【多態(tài)樣式】 通用屬性

    設置組件不同狀態(tài)的樣式。 從API version 9開始,該接口支持ArkTS卡片中使用。
    的頭像 發(fā)表于 06-07 09:48 ?934次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>聲明</b><b class='flag-5'>式</b><b class='flag-5'>開發(fā)</b>:<b class='flag-5'>跨</b><b class='flag-5'>平臺</b><b class='flag-5'>支持</b><b class='flag-5'>列表</b>【多態(tài)樣式】 <b class='flag-5'>通用</b><b class='flag-5'>屬性</b>

    鴻蒙ArkTS聲明開發(fā)平臺支持列表【分布遷移標識】 通用屬性

    組件的分布遷移標識,指明了該組件在分布遷移場景下可以將特定狀態(tài)恢復到對端設備。
    的頭像 發(fā)表于 06-07 21:15 ?782次閱讀

    鴻蒙ArkTS聲明開發(fā)平臺支持列表【無障礙屬性通用屬性

    組件可以設置相應的無障礙屬性和事件來更好地使用無障礙能力。
    的頭像 發(fā)表于 06-11 17:30 ?961次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>聲明</b><b class='flag-5'>式</b><b class='flag-5'>開發(fā)</b>:<b class='flag-5'>跨</b><b class='flag-5'>平臺</b><b class='flag-5'>支持</b><b class='flag-5'>列表</b>【無障礙<b class='flag-5'>屬性</b>】 <b class='flag-5'>通用</b><b class='flag-5'>屬性</b>

    鴻蒙ArkTS聲明開發(fā)平臺支持列表【文本通用

    文本通用屬性目前只針對包含文本元素的組件,設置文本樣式。
    的頭像 發(fā)表于 06-13 15:09 ?1192次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>ArkTS</b><b class='flag-5'>聲明</b><b class='flag-5'>式</b><b class='flag-5'>開發(fā)</b>:<b class='flag-5'>跨</b><b class='flag-5'>平臺</b><b class='flag-5'>支持</b><b class='flag-5'>列表</b>【文本<b class='flag-5'>通用</b>】