溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

DependentLayout布局方法是什么

發(fā)布時間:2021-10-23 13:51:01 來源:億速云 閱讀:149 作者:iii 欄目:編程語言

這篇文章主要講解了“DependentLayout布局方法是什么”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“DependentLayout布局方法是什么”吧!

 DependentLayout簡介

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

常用屬性

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

DependentLayout布局方法是什么

xmlns:ohos="http://schemas.huawei.com/res/ohos"  ohos:height="match_parent"  ohos:width="match_parent"  ohos:alignment="center">   ohos:id="$+id:text_01"  ohos:height="match_content"  ohos:width="match_content"  ohos:background_element="$graphic:background_dependent_layout"  ohos:text="我是第一個Text."  ohos:text_size="50"  />   ohos:id="$+id:text_02"  ohos:height="match_content"  ohos:width="match_content"  ohos:background_element="$graphic:background_dependent_layout"  ohos:text="我是第二個Text."  ohos:text_size="50"  ohos:above="$id:text_01"  />

 DependentLayout布局方法是什么

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

DependentLayout布局方法是什么

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

DependentLayout布局方法是什么

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

DependentLayout布局方法是什么

xmlns:ohos="http://schemas.huawei.com/res/ohos"  ohos:height="match_parent"  ohos:width="match_parent"  ohos:alignment="center">   ohos:id="$+id:text_01"  ohos:height="match_content"  ohos:width="match_content"  ohos:background_element="$graphic:background_dependent_layout"  ohos:text="我是第一個Text."  ohos:text_size="50"  ohos:align_parent_bottom="true"  />   ohos:id="$+id:text_02"  ohos:height="match_content"  ohos:width="match_content"  ohos:background_element="$graphic:background_dependent_layout"  ohos:text="我是第二個Text."  ohos:text_size="50"  ohos:align_parent_top="true"  />   ohos:id="$+id:text_03"  ohos:height="match_content"  ohos:width="match_content"  ohos:background_element="$graphic:background_dependent_layout"  ohos:text="我是第三個Text."  ohos:text_size="50"  ohos:align_parent_right="true"  />   ohos:id="$+id:text_04"  ohos:height="match_content"  ohos:width="match_content"  ohos:background_element="$graphic:background_dependent_layout"  ohos:text="我是第四個Text."  ohos:text_size="50"  ohos:center_in_parent="true"  />

 DependentLayout布局方法是什么

示例

xmlns:ohos="http://schemas.huawei.com/res/ohos"  ohos:height="match_parent"  ohos:width="match_parent">   ohos:id="$+id:text_01"  ohos:height="70vp"  ohos:width="match_parent"  ohos:background_element="#CCCCCC"  ohos:text="Header"  ohos:text_alignment="center"  ohos:text_size="50"  ohos:align_parent_top="true"  />   ohos:id="$+id:text_02"  ohos:height="match_parent"  ohos:width="100vp"  ohos:background_element="#5C6E71"  ohos:text="LEFT"  ohos:text_alignment="center"  ohos:text_size="50"  ohos:align_parent_left="true"  ohos:below="$id:text_01"  />   ohos:id="$+id:text_03"  ohos:height="match_parent"  ohos:width="100vp"  ohos:background_element="#5C6E71"  ohos:text="Right"  ohos:text_alignment="center"  ohos:text_size="50"  ohos:align_parent_right="true"  ohos:below="$id:text_01"  />   ohos:id="$+id:text_05"  ohos:height="match_parent"  ohos:width="match_parent"  ohos:background_element="#16CCB7"  ohos:text_alignment="center"  ohos:text="Center"  ohos:text_size="50"  ohos:right_margin="100vp"  ohos:below="$id:text_01"  ohos:right_of="$id:text_02"  />   ohos:id="$+id:text_04"  ohos:height="50vp"  ohos:width="match_parent"  ohos:background_element="#CCCCCC"  ohos:text="Footer"  ohos:text_size="50"  ohos:align_parent_bottom="true"  />

 DependentLayout布局方法是什么

感謝各位的閱讀,以上就是“DependentLayout布局方法是什么”的內容了,經(jīng)過本文的學習后,相信大家對DependentLayout布局方法是什么這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。

AI