日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

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

新聞中心

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

想了解更多內(nèi)容,請(qǐng)?jiān)L問:

成都創(chuàng)新互聯(lián)自2013年創(chuàng)立以來,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元康平做網(wǎng)站,已為上家服務(wù),為康平各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:028-86922220

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

https://harmonyos./#zz

TableLayout簡(jiǎn)介

TableLayout意為表格布局,也可以稱為網(wǎng)格布局,允許我們使用表格的方式來排列組件,也就是行和列的方式。

TableLayout提供了用于在表格中對(duì)齊和排列組件的接口。可配置表格的排列方式,行數(shù)和列數(shù),以及組件的位置。

常用屬性

ohos:alignment_type表示設(shè)置網(wǎng)格布局中的對(duì)齊方式,默認(rèn)為align_contents(表示頁邊距對(duì)齊),還有一個(gè)參數(shù)是align_edges(表示邊界對(duì)齊)。

 
 
 
 
  1. xmlns:ohos="http://schemas.huawei.com/res/ohos" 
  2.  
  3. ohos:id="$+id:tableLayout" 
  4.  
  5. ohos:height="match_parent" 
  6.  
  7. ohos:width="match_parent" 
  8.  
  9. ohos:alignment_type="align_contents" 
  10.  
  11. ohos:background_element="#8AA7AA"> 

 ohos:row_count表示設(shè)置網(wǎng)格布局中行數(shù),ohos:column_count表示設(shè)置網(wǎng)格布局中的列數(shù)。如果沒有為子組件設(shè)置值,則使用父組件默認(rèn)的行數(shù)和列數(shù)。在網(wǎng)格布局中若子組件的數(shù)量超出列數(shù)設(shè)置,則會(huì)自動(dòng)添加行數(shù)。比如下列代碼,我們?cè)O(shè)置一行,兩列,但是是三個(gè)子組件,我們監(jiān)聽其中一個(gè)按鈕的點(diǎn)擊事件,將行列數(shù)顯示在文本組件中。

 
 
 
 
  1. xmlns:ohos="http://schemas.huawei.com/res/ohos" 
  2.  
  3. ohos:id="$+id:tableLayout" 
  4.  
  5. ohos:height="match_content" 
  6.  
  7. ohos:width="match_content" 
  8.  
  9. ohos:row_count="1" 
  10.  
  11. ohos:column_count="2" 
  12.  
  13. ohos:background_element="#8AA7AA"> 
  14.  
  15.  
  16. ohos:id="$+id:tableTxt" 
  17.  
  18. ohos:height="match_content" 
  19.  
  20. ohos:width="match_content" 
  21.  
  22. ohos:text="我是文本組件" 
  23.  
  24. ohos:text_size="20fp"/> 
  25.  
  26.  
  27. ohos:id="$+id:button" 
  28.  
  29. ohos:height="match_content" 
  30.  
  31. ohos:width="match_content" 
  32.  
  33. ohos:text="我是第一個(gè)按鈕" 
  34.  
  35. ohos:background_element="#5C6E71" 
  36.  
  37. ohos:text_color="#FFFFFF" 
  38.  
  39. ohos:text_size="20fp"/> 
  40.  
  41.  
  42. ohos:id="$+id:btn" 
  43.  
  44. ohos:height="match_content" 
  45.  
  46. ohos:width="match_content" 
  47.  
  48. ohos:text="我是第二個(gè)按鈕" 
  49.  
  50. ohos:background_element="#5C6E71" 
  51.  
  52. ohos:text_color="#FFFFFF" 
  53.  
  54. ohos:text_size="20fp"/> 

 未觸發(fā)按鈕點(diǎn)擊事件的時(shí)候頁面顯示效果。

觸發(fā)按鈕點(diǎn)擊事件的時(shí)候頁面顯示效果。

ohos:orientation表示設(shè)置表格中組件的排列方式,水平(vertical)和垂直(horizontal)。如果我們?cè)O(shè)置行為1,列為2,子組件三個(gè),設(shè)置水平方向顯示,那么我們的列將失效,自動(dòng)會(huì)添加一列。

 
 
 
 
  1. xmlns:ohos="http://schemas.huawei.com/res/ohos" 
  2.  
  3. ohos:id="$+id:tableLayout" 
  4.  
  5. ohos:height="match_parent" 
  6.  
  7. ohos:width="match_parent" 
  8.  
  9. ohos:orientation="horizontal" 
  10.  
  11. ohos:background_element="#8AA7AA"> 
 
 
 
 
  1. xmlns:ohos="http://schemas.huawei.com/res/ohos" 
  2.  
  3. ohos:id="$+id:tableLayout" 
  4.  
  5. ohos:height="match_parent" 
  6.  
  7. ohos:width="match_parent" 
  8.  
  9. ohos:orientation="vertical" 
  10.  
  11. ohos:background_element="#8AA7AA"> 

示例

 
 
 
 
  1. xmlns:ohos="http://schemas.huawei.com/res/ohos" 
  2.  
  3. ohos:id="$+id:tableLayout" 
  4.  
  5. ohos:height="match_parent" 
  6.  
  7. ohos:width="match_parent" 
  8.  
  9. ohos:row_count="3" 
  10.  
  11. ohos:column_count="5" 
  12.  
  13. ohos:background_element="#8AA7AA"> 
  14.  
  15.  
  16. ohos:height="match_content" 
  17.  
  18. ohos:width="match_content" 
  19.  
  20. ohos:text="我是第1個(gè)按鈕" 
  21.  
  22. ohos:background_element="#07CCFF" 
  23.  
  24. ohos:text_color="#FFFFFF" 
  25.  
  26. ohos:text_size="20fp" 
  27.  
  28. ohos:padding="10vp"/> 
  29.  
  30. ..... 

想了解更多內(nèi)容,請(qǐng)?jiān)L問:

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

https://harmonyos./#zz


分享標(biāo)題:鴻蒙HarmonyOSJavaUI之TableLayout布局示例
網(wǎng)頁地址:http://www.dlmjj.cn/article/dpopecs.html