日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
鴻蒙HarmonyOSJavaUI之DependentLayout布局示例

想了解更多內(nèi)容,請訪問:

專業(yè)成都網(wǎng)站建設(shè)公司,做排名好的好網(wǎng)站,排在同行前面,為您帶來客戶和效益!成都創(chuàng)新互聯(lián)公司為您提供成都網(wǎng)站建設(shè),五站合一網(wǎng)站設(shè)計制作,服務(wù)好的網(wǎng)站設(shè)計公司,網(wǎng)站設(shè)計、成都網(wǎng)站建設(shè)負責任的成都網(wǎng)站制作公司!

和華為官方合作共建的鴻蒙技術(shù)社區(qū)

https://harmonyos./#zz

 DependentLayout簡介

DependentLayout意為相對位置布局,與DirectionalLayout相比較有更多的排布方式,每個組件可以指定相對于其他同級組件的位置,也可以指定相對于父組件的位置。可以使用DependentLayout布局來實現(xiàn)更加復(fù)雜的UI界面,同時也可以和其他布局相結(jié)合組合出需要的UI界面。

常用屬性

相對于指定組件的位置屬性

 
 
 
 
  1. xmlns:ohos="http://schemas.huawei.com/res/ohos" 
  2.  
  3. ohos:height="match_parent" 
  4.  
  5. ohos:width="match_parent" 
  6.  
  7. ohos:alignment="center"> 
  8.  
  9.  
  10. ohos:id="$+id:text_01" 
  11.  
  12. ohos:height="match_content" 
  13.  
  14. ohos:width="match_content" 
  15.  
  16. ohos:background_element="$graphic:background_dependent_layout" 
  17.  
  18. ohos:text="我是第一個Text." 
  19.  
  20. ohos:text_size="50" 
  21.  
  22. /> 
  23.  
  24.  
  25. ohos:id="$+id:text_02" 
  26.  
  27. ohos:height="match_content" 
  28.  
  29. ohos:width="match_content" 
  30.  
  31. ohos:background_element="$graphic:background_dependent_layout" 
  32.  
  33. ohos:text="我是第二個Text." 
  34.  
  35. ohos:text_size="50" 
  36.  
  37. ohos:above="$id:text_01" 
  38.  
  39. /> 

 

將ohos:above="$id:text_01" 改為ohos:below="$id:text_01",效果如下。

將ohos:above="$id:text_01" 改為ohos:left_of="$id:text_01",效果如下,其他自行驗證。

子組件相對于父組件的位置屬性

 
 
 
 
  1. xmlns:ohos="http://schemas.huawei.com/res/ohos" 
  2.  
  3. ohos:height="match_parent" 
  4.  
  5. ohos:width="match_parent" 
  6.  
  7. ohos:alignment="center"> 
  8.  
  9.  
  10. ohos:id="$+id:text_01" 
  11.  
  12. ohos:height="match_content" 
  13.  
  14. ohos:width="match_content" 
  15.  
  16. ohos:background_element="$graphic:background_dependent_layout" 
  17.  
  18. ohos:text="我是第一個Text." 
  19.  
  20. ohos:text_size="50" 
  21.  
  22. ohos:align_parent_bottom="true" 
  23.  
  24. /> 
  25.  
  26.  
  27. ohos:id="$+id:text_02" 
  28.  
  29. ohos:height="match_content" 
  30.  
  31. ohos:width="match_content" 
  32.  
  33. ohos:background_element="$graphic:background_dependent_layout" 
  34.  
  35. ohos:text="我是第二個Text." 
  36.  
  37. ohos:text_size="50" 
  38.  
  39. ohos:align_parent_top="true" 
  40.  
  41. /> 
  42.  
  43.  
  44. ohos:id="$+id:text_03" 
  45.  
  46. ohos:height="match_content" 
  47.  
  48. ohos:width="match_content" 
  49.  
  50. ohos:background_element="$graphic:background_dependent_layout" 
  51.  
  52. ohos:text="我是第三個Text." 
  53.  
  54. ohos:text_size="50" 
  55.  
  56. ohos:align_parent_right="true" 
  57.  
  58. /> 
  59.  
  60.  
  61. ohos:id="$+id:text_04" 
  62.  
  63. ohos:height="match_content" 
  64.  
  65. ohos:width="match_content" 
  66.  
  67. ohos:background_element="$graphic:background_dependent_layout" 
  68.  
  69. ohos:text="我是第四個Text." 
  70.  
  71. ohos:text_size="50" 
  72.  
  73. ohos:center_in_parent="true" 
  74.  
  75. /> 

 

示例

 
 
 
 
  1. xmlns:ohos="http://schemas.huawei.com/res/ohos" 
  2.  
  3. ohos:height="match_parent" 
  4.  
  5. ohos:width="match_parent"> 
  6.  
  7.  
  8. ohos:id="$+id:text_01" 
  9.  
  10. ohos:height="70vp" 
  11.  
  12. ohos:width="match_parent" 
  13.  
  14. ohos:background_element="#CCCCCC" 
  15.  
  16. ohos:text="Header" 
  17.  
  18. ohos:text_alignment="center" 
  19.  
  20. ohos:text_size="50" 
  21.  
  22. ohos:align_parent_top="true" 
  23.  
  24. /> 
  25.  
  26.  
  27. ohos:id="$+id:text_02" 
  28.  
  29. ohos:height="match_parent" 
  30.  
  31. ohos:width="100vp" 
  32.  
  33. ohos:background_element="#5C6E71" 
  34.  
  35. ohos:text="LEFT" 
  36.  
  37. ohos:text_alignment="center" 
  38.  
  39. ohos:text_size="50" 
  40.  
  41. ohos:align_parent_left="true" 
  42.  
  43. ohos:below="$id:text_01" 
  44.  
  45. /> 
  46.  
  47.  
  48. ohos:id="$+id:text_03" 
  49.  
  50. ohos:height="match_parent" 
  51.  
  52. ohos:width="100vp" 
  53.  
  54. ohos:background_element="#5C6E71" 
  55.  
  56. ohos:text="Right" 
  57.  
  58. ohos:text_alignment="center" 
  59.  
  60. ohos:text_size="50" 
  61.  
  62. ohos:align_parent_right="true" 
  63.  
  64. ohos:below="$id:text_01" 
  65.  
  66. /> 
  67.  
  68.  
  69. ohos:id="$+id:text_05" 
  70.  
  71. ohos:height="match_parent" 
  72.  
  73. ohos:width="match_parent" 
  74.  
  75. ohos:background_element="#16CCB7" 
  76.  
  77. ohos:text_alignment="center" 
  78.  
  79. ohos:text="Center" 
  80.  
  81. ohos:text_size="50" 
  82.  
  83. ohos:right_margin="100vp" 
  84.  
  85. ohos:below="$id:text_01" 
  86.  
  87. ohos:right_of="$id:text_02" 
  88.  
  89. /> 
  90.  
  91.  
  92. ohos:id="$+id:text_04" 
  93.  
  94. ohos:height="50vp" 
  95.  
  96. ohos:width="match_parent" 
  97.  
  98. ohos:background_element="#CCCCCC" 
  99.  
  100. ohos:text="Footer" 
  101.  
  102. ohos:text_size="50" 
  103.  
  104. ohos:align_parent_bottom="true" 
  105.  
  106. /> 

 

至此,我們已經(jīng)了解并會使用HarmonyOS Java UI的六大布局,下一節(jié)我們將對六大布局進行總結(jié),并將前面沒有提到的各類屬性做詳細的歸納。

想了解更多內(nèi)容,請訪問:

和華為官方合作共建的鴻蒙技術(shù)社區(qū)

https://harmonyos./#zz


分享標題:鴻蒙HarmonyOSJavaUI之DependentLayout布局示例
網(wǎng)頁網(wǎng)址:http://www.5511xx.com/article/copsisg.html