成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

HarmonyOS APP組件分享(四)

系統 OpenHarmony
文章由鴻蒙社區產出,想要了解更多內容請前往:51CTO和華為官方戰略合作共建的鴻蒙技術社區https://harmonyos.51cto.com

想了解更多內容,請訪問:

51CTO和華為官方合作共建的鴻蒙技術社區

https://harmonyos.51cto.com

HarmonyOS APP - RadioButton+RadioContainer體驗與分享

這里敲了RadioButton+RadioContainer的一個小案例,簡單做了一個多選和單選的選擇題。

RadioButton我們可以用在多重選擇的時候使用該組件,方便用戶做出多種選擇。

RadioContainer這個是用于單選,可以用于唯一答案的選擇例如男女選項。

代碼如下:

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <DirectionalLayout 
  3.     xmlns:ohos="http://schemas.huawei.com/res/ohos" 
  4.     ohos:height="match_parent" 
  5.     ohos:width="match_parent" 
  6.     ohos:orientation="vertical"
  7.  
  8.     <DirectionalLayout 
  9.         ohos:height="500px" 
  10.         ohos:width="match_parent" 
  11.         ohos:orientation="vertical"
  12.         <Text 
  13.             ohos:height="80px" 
  14.             ohos:width="match_parent" 
  15.             ohos:text="周末都在家干些啥呢(多選)。" 
  16.             ohos:text_size="18fp"/> 
  17.         <DirectionalLayout 
  18.             ohos:height="400px" 
  19.             ohos:width="match_parent" 
  20.             ohos:orientation="vertical"
  21.             <DirectionalLayout 
  22.                 ohos:height="100px" 
  23.                 ohos:width="match_parent" 
  24.                 ohos:orientation="horizontal"
  25.                 <RadioButton 
  26.                     ohos:id="$+id:rb_1" 
  27.                     ohos:height="40vp" 
  28.                     ohos:width="0px" 
  29.                     ohos:weight="1" 
  30.                     ohos:text="A.吃飯" 
  31.                     ohos:text_size="20fp" 
  32.                     ohos:text_color_on="#00BFFF" 
  33.                     ohos:text_color_off="#808080" 
  34.                     /> 
  35.                 <RadioButton 
  36.                     ohos:id="$+id:rb_2" 
  37.                     ohos:height="40vp" 
  38.                     ohos:width="0px" 
  39.                     ohos:weight="1" 
  40.                     ohos:text="B.睡覺" 
  41.                     ohos:text_size="20fp" 
  42.                     ohos:text_color_on="#00BFFF" 
  43.                     ohos:text_color_off="#808080"/> 
  44.             </DirectionalLayout> 
  45.             <DirectionalLayout 
  46.                 ohos:height="100px" 
  47.                 ohos:width="match_parent" 
  48.                 ohos:orientation="horizontal"
  49.                 <RadioButton 
  50.                     ohos:id="$+id:rb_3" 
  51.                     ohos:height="40vp" 
  52.                     ohos:width="0px" 
  53.                     ohos:weight="1" 
  54.                     ohos:text="C.打豆豆" 
  55.                     ohos:text_size="20fp" 
  56.                     ohos:text_color_on="#00BFFF" 
  57.                     ohos:text_color_off="#808080" 
  58.                     /> 
  59.                 <RadioButton 
  60.                     ohos:id="$+id:rb_4" 
  61.                     ohos:height="40vp" 
  62.                     ohos:width="0px" 
  63.                     ohos:weight="1" 
  64.                     ohos:text="D.學習" 
  65.                     ohos:text_size="20fp" 
  66.                     ohos:text_color_on="#00BFFF" 
  67.                     ohos:text_color_off="#808080"/> 
  68.             </DirectionalLayout> 
  69.             <DirectionalLayout 
  70.                 ohos:height="100px" 
  71.                 ohos:width="match_parent" 
  72.                 ohos:orientation="horizontal"
  73.                 <RadioButton 
  74.                     ohos:id="$+id:rb_5" 
  75.                     ohos:height="40vp" 
  76.                     ohos:width="0px" 
  77.                     ohos:weight="1" 
  78.                     ohos:text="E.看電視" 
  79.                     ohos:text_size="20fp" 
  80.                     ohos:text_color_on="#00BFFF" 
  81.                     ohos:text_color_off="#808080" 
  82.                     /> 
  83.                 <RadioButton 
  84.                     ohos:id="$+id:rb_6" 
  85.                     ohos:height="40vp" 
  86.                     ohos:width="0px" 
  87.                     ohos:weight="1" 
  88.                     ohos:text="F.敲代碼" 
  89.                     ohos:text_size="20fp" 
  90.                     ohos:text_color_on="#00BFFF" 
  91.                     ohos:text_color_off="#808080"/> 
  92.             </DirectionalLayout> 
  93.         </DirectionalLayout> 
  94.     </DirectionalLayout> 
  95.     <DirectionalLayout 
  96.         ohos:height="700px" 
  97.         ohos:width="match_parent" 
  98.         ohos:orientation="vertical"
  99.         <DirectionalLayout 
  100.             ohos:height="200px" 
  101.             ohos:width="match_parent"
  102.             <Text 
  103.                 ohos:height="100px" 
  104.                 ohos:width="match_parent" 
  105.                 ohos:text="單選題(紅錯,藍對)" 
  106.                 ohos:text_size="20fp"/> 
  107.             <Text 
  108.                 ohos:height="100px" 
  109.                 ohos:width="match_parent" 
  110.                 ohos:text="下面那個是屬于動物?" 
  111.                 ohos:text_size="20fp"/> 
  112.         </DirectionalLayout> 
  113.         <RadioContainer 
  114.             ohos:height="500px" 
  115.             ohos:width="match_content"
  116.             <RadioButton 
  117.                 ohos:id="$+id:radio_button_1" 
  118.                 ohos:height="40vp" 
  119.                 ohos:width="match_content" 
  120.                 ohos:text="A.蘋果" 
  121.                 ohos:text_size="20fp" 
  122.                 ohos:text_color_on="red" 
  123.                 ohos:text_color_off="#808080"/> 
  124.             <RadioButton 
  125.                 ohos:id="$+id:radio_button_2" 
  126.                 ohos:height="40vp" 
  127.                 ohos:width="match_content" 
  128.                 ohos:text="B.香蕉" 
  129.                 ohos:text_size="20fp" 
  130.                 ohos:text_color_on="red" 
  131.                 ohos:text_color_off="#808080"/> 
  132.             <RadioButton 
  133.                 ohos:id="$+id:radio_button_3" 
  134.                 ohos:height="40vp" 
  135.                 ohos:width="match_content" 
  136.                 ohos:text="C.小狗" 
  137.                 ohos:text_size="20fp" 
  138.                 ohos:text_color_on="#00BFFF" 
  139.                 ohos:text_color_off="#808080"/> 
  140.             <RadioButton 
  141.                 ohos:id="$+id:radio_button_4" 
  142.                 ohos:height="40vp" 
  143.                 ohos:width="match_content" 
  144.                 ohos:text="D.葡萄" 
  145.                 ohos:text_size="20fp" 
  146.                 ohos:text_color_on="red" 
  147.                 ohos:text_color_off="#808080"/> 
  148.  
  149.         </RadioContainer> 
  150.     </DirectionalLayout> 
  151.     <DirectionalLayout 
  152.         ohos:height="600px" 
  153.         ohos:width="match_parent" 
  154.         ohos:orientation="vertical"
  155.         <DirectionalLayout 
  156.             ohos:height="100px" 
  157.             ohos:width="match_parent"
  158.             <Text 
  159.                 ohos:height="match_parent" 
  160.                 ohos:width="match_parent" 
  161.                 ohos:text="下面那個是屬于水果?" 
  162.                 ohos:text_size="20fp"/> 
  163.         </DirectionalLayout> 
  164.         <RadioContainer 
  165.             ohos:height="500px" 
  166.             ohos:width="match_content"
  167.             <RadioButton 
  168.                 ohos:height="40vp" 
  169.                 ohos:width="match_content" 
  170.                 ohos:text="A.小狗" 
  171.                 ohos:text_size="20fp" 
  172.                 ohos:text_color_on="red" 
  173.                 ohos:text_color_off="#808080"/> 
  174.             <RadioButton 
  175.                 ohos:height="40vp" 
  176.                 ohos:width="match_content" 
  177.                 ohos:text="B.黑鳳梨" 
  178.                 ohos:text_size="20fp" 
  179.                 ohos:text_color_on="#00BFFF" 
  180.                 ohos:text_color_off="#808080"/> 
  181.             <RadioButton 
  182.                 ohos:height="40vp" 
  183.                 ohos:width="match_content" 
  184.                 ohos:text="C.小貓" 
  185.                 ohos:text_size="20fp" 
  186.                 ohos:text_color_on="red" 
  187.                 ohos:text_color_off="#808080"/> 
  188.             <RadioButton 
  189.                 ohos:height="40vp" 
  190.                 ohos:width="match_content" 
  191.                 ohos:text="D.小馬" 
  192.                 ohos:text_size="20fp" 
  193.                 ohos:text_color_on="red" 
  194.                 ohos:text_color_off="#808080"/> 
  195.  
  196.         </RadioContainer> 
  197.     </DirectionalLayout> 
  198.  
  199. </DirectionalLayout> 

完整代碼下載地址:

https://gitee.com/jltfcloudcn/jump_to/tree/master/jltf_RadioButton+RadioContainer_component

HarmonyOS APP - Switch體驗與分享

Switch是切換單個設置開/關兩種狀態的組件。我們體驗效果如下。

顯示效果:

滑動按鈕:

代碼如下:

布局中

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <DirectionalLayout 
  3.     xmlns:ohos="http://schemas.huawei.com/res/ohos" 
  4.     ohos:height="match_parent" 
  5.     ohos:width="match_parent" 
  6.     ohos:orientation="vertical"
  7.  
  8.     <Switch 
  9.         ohos:id="$+id:btn_switch" 
  10.         ohos:height="30vp" 
  11.         ohos:width="60vp" 
  12.         ohos:top_margin="40px" 
  13.         ohos:left_margin="400px" 
  14.         ohos:text_state_off="OFF" 
  15.         ohos:text_state_on="ON"/> 
  16.  
  17. </DirectionalLayout> 

完整源碼地址:

https://gitee.com/jltfcloudcn/jump_to/tree/master/jltf_switch_component

想了解更多內容,請訪問:

51CTO和華為官方合作共建的鴻蒙技術社區

https://harmonyos.51cto.com

 

責任編輯:jianghua 來源: 鴻蒙社區
相關推薦

2021-03-17 09:35:09

鴻蒙HarmonyOS應用開發

2021-03-30 09:45:07

鴻蒙HarmonyOS應用開發

2021-03-31 15:49:34

鴻蒙HarmonyOS應用

2021-03-18 09:36:02

鴻蒙HarmonyOS應用

2012-04-28 21:25:58

APP

2021-03-22 09:48:32

鴻蒙HarmonyOS應用開發

2011-03-31 14:07:27

Java

2021-01-11 11:36:23

鴻蒙HarmonyOSApp開發

2022-02-10 15:14:50

HarmonyOS操作系統鴻蒙

2010-07-28 12:41:18

Flex組件

2013-12-16 09:36:08

App項目

2021-01-14 09:50:26

鴻蒙HarmonyOSAPP

2022-08-01 07:56:23

React Hook開發組件

2016-12-09 09:23:50

android組件Service

2022-07-23 21:37:48

Python

2010-08-05 10:22:46

Flex效果

2013-01-10 12:57:23

產品經理App產品設計

2013-04-28 13:52:05

app

2015-03-24 20:07:18

APP推廣APP運營

2011-11-08 11:03:26

App Store蘋果應用推廣
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 九九热精品视频 | 精品美女久久久久久免费 | 99在线免费观看 | 99re | 成人欧美一区二区三区在线播放 | 天天搞天天操 | 雨宫琴音一区二区在线 | 成人精品一区二区户外勾搭野战 | 欧美精品啪啪 | 国产精品毛片无码 | 九九国产| 久久aⅴ乱码一区二区三区 亚洲国产成人精品久久久国产成人一区 | 欧美日韩精品 | 一区二区精品 | 亚洲精品乱码久久久久久按摩 | 亚洲一区精品在线 | 亚洲精品一区二区在线观看 | 亚洲自拍一区在线观看 | 久在线| 91视频一区 | 亚洲自拍偷拍欧美 | 日韩中文一区二区三区 | 国产一区二区三区四区三区四 | 久久精品久久久久久 | 欧美videosex性极品hd | 亚洲国产一区二区在线 | 亚洲精品视频在线 | 精品亚洲视频在线 | 91香蕉视频在线观看 | 免费毛片网| 成人在线免费观看视频 | 九九久久久| www.国产日本 | 国产成人免费在线 | 美日韩免费视频 | 亚洲精品www.| 日本韩国欧美在线观看 | 国产精品美女久久久久久久久久久 | 亚洲在线看 | 欧美精品中文字幕久久二区 | 久久综合久久久 |