当父组件空间不够时,根据空间的大小,优先级高的组件优先显示,优先级低的只在空间足够时才显示?

当父组件空间不够时,根据空间的大小,优先级高的组件优先显示,优先级低的只在空间足够时才显示?


HarmonyOS
2024-07-28 09:15:26
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
jshyb

如下代码:4个Text的优先级分别为4,3,2,1。数字越大,表示优先级越高。如图当父组件只能显示3个组件时,优先级为1的组件隐藏。

Row() {
  Text().width(40)
    .height(40)
    .margin(10)
    .backgroundColor(Color.White)
    .displayPriority(4)
  Text().width(40)
    .height(40)
    .margin(10)
    .backgroundColor(Color.Orange)
    .displayPriority(3)
  Text().width(40)
    .height(40)
    .margin(10)
    .backgroundColor(Color.Red)
    .displayPriority(2)
  Text().width(40)
    .height(40)
    .margin(10)
    .backgroundColor(Color.Blue)
    .displayPriority(1)
}
.justifyContent(FlexAlign.Center)
.width(200)
.height(150)
.backgroundColor(Color.Grey)
  • 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.

分享
微博
QQ
微信
回复
2024-07-28 20:40:26
相关问题
HarmonyOS resource优先级
713浏览 • 1回复 待解决
设置Task优先级方法
1333浏览 • 1回复 待解决
多模态交互优先级策略
299浏览 • 0回复 待解决
HarmonyOS 主线程优先级是多少?
946浏览 • 1回复 待解决
HarmonyOS能否支持网络优先级调度?
1092浏览 • 1回复 待解决
如何获知TaskPool执行顺序、优先级
1629浏览 • 0回复 待解决
求大佬告知如何设置Task优先级
2407浏览 • 1回复 待解决
如何设置约束优先级,有人知道吗?
1282浏览 • 2回复 待解决