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

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

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
HarmonyOS之時鐘FA卡片開發(fā)樣例實(shí)踐

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

為玄武等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及玄武網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都網(wǎng)站設(shè)計、成都做網(wǎng)站、玄武網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!

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

https://harmonyos.

時鐘FA卡片開發(fā)樣例

介紹

服務(wù)卡片是FA的一種主要信息呈現(xiàn)形式,開發(fā)者可以在卡片中展示用戶最關(guān)心的FA數(shù)據(jù),并可以通過點(diǎn)擊卡片內(nèi)容直接打開FA。例如,天氣類FA,可以在服務(wù)卡片中展示當(dāng)前的基本天氣信息,點(diǎn)擊卡片啟動天氣FA,展示詳細(xì)的天氣數(shù)據(jù)。

同時,服務(wù)卡片支持不同的規(guī)格尺寸,開發(fā)者可以根據(jù)展示的不同內(nèi)容和布局效果,選用不同的卡片尺寸,支持的尺寸包括:1x2、2x2、2x4 和 4x4。

知識點(diǎn):

1.對象關(guān)系型數(shù)據(jù)庫的使用,如何查詢、創(chuàng)建卡片、刪除卡片

2.如何更新卡片數(shù)據(jù)

搭建環(huán)境

安裝DevEco Studio,詳情請參考DevEco Studio下載。

設(shè)置DevEco Studio開發(fā)環(huán)境,DevEco Studio開發(fā)環(huán)境需要依賴于網(wǎng)絡(luò)環(huán)境,需要連接上網(wǎng)絡(luò)才能確保工具的正常使用,可以根據(jù)如下兩種情況來配置開發(fā)環(huán)境:

如果可以直接訪問Internet,只需進(jìn)行下載HarmonyOS SDK操作。

如果網(wǎng)絡(luò)不能直接訪問Internet,需要通過代理服務(wù)器才可以訪問,請參考配置開發(fā)環(huán)境。

代碼結(jié)構(gòu)解讀

 
 
 
 
  1. ├─config.json #項(xiàng)目配置文件
  2. ├─java
  3. │  └─com
  4. │      └─huawei
  5. │          └─learnharmony
  6. │              │  MainAbility.java
  7. │              │  MyApplication.java
  8. │              │  TimerAbility.java  #用于定時更新卡片的服務(wù)
  9. │              │
  10. │              ├─database
  11. │              │      Form.java #卡片表,extends OrmObject 
  12. │              │      FormDatabase.java #卡片數(shù)據(jù)庫,extends OrmDatabase
  13. │              │
  14. │              ├─slice
  15. │              │      ClockCardSlice.java #時鐘卡片主能力頁,extends AbilitySlice
  16. │              │
  17. │              └─utils
  18. │                      ComponentProviderUtils.java #ComponentProvider工具類
  19. │                      DatabaseUtils.java #數(shù)據(jù)庫工具類,實(shí)現(xiàn)Form的添加和刪除
  20. │                      DateUtils.java  #日期工具類
  21. │                      LogUtils.java #日志工具類
  22. └─resources
  23.     └─base
  24.         ├─element
  25.         │      string.json
  26.         │
  27.         ├─graphic
  28.         │      background_ability_main.xml
  29.         │      background_week.xml
  30.         │
  31.         ├─layout
  32.         │      ability_main.xml #主能力頁,默認(rèn)
  33.         │      form_image_with_info_date_card_1_2.xml #1x2規(guī)格的卡片
  34.         │      form_image_with_info_date_card_2_2.xml #2x2規(guī)格的卡片
  35.         │      form_image_with_info_date_card_2_4.xml #2x4規(guī)格的卡片
  36.         │
  37.         └─media
  38.                 form_image_with_info_datecard_default_image_2.png
  39.                 form_image_with_info_form_card_default_image_2.png
  40.                 icon.png

卡片布局

form_image_with_info_date_card_1_2.xml #1x2規(guī)格的卡片

 
 
 
 
  1.     xmlns:ohos="http://schemas.huawei.com/res/ohos"
  2.     ohos:height="match_parent"
  3.     ohos:width="match_parent"
  4.     ohos:background_element="#FFFFFFFF"
  5.     ohos:remote="true">
  6.     
  7.         ohos:height="match_content"
  8.         ohos:width="match_parent"
  9.         ohos:orientation="vertical"
  10.         ohos:vertical_center="true"
  11.         >
  12.         
  13.             ohos:id="$+id:date"
  14.             ohos:height="match_content"
  15.             ohos:width="match_content"
  16.             ohos:center_in_parent="true"
  17.             ohos:text="2021-03-24"
  18.             ohos:text_alignment="vertical_center"
  19.             ohos:text_font="sans-serif-medium"
  20.             ohos:text_size="20fp"
  21.             />
  22.     

form_image_with_info_date_card_2_2.xml #2x2規(guī)格的卡片

 
 
 
 
  1.     xmlns:ohos="http://schemas.huawei.com/res/ohos"
  2.     ohos:height="match_parent"
  3.     ohos:width="match_parent"
  4.     ohos:background_element="#FFFFFFFF"
  5.     ohos:remote="true">
  6.     
  7.         ohos:height="match_content"
  8.         ohos:width="match_parent"
  9.         ohos:orientation="vertical"
  10.         >
  11.         
  12.             ohos:id="$+id:date"
  13.             ohos:height="match_content"
  14.             ohos:width="match_parent"
  15.             ohos:text_alignment="horizontal_center"
  16.             ohos:margin="12fp"
  17.             ohos:text="2021-03-24"
  18.             ohos:text_font="sans-serif-medium"
  19.             ohos:text_size="10fp"
  20.             />
  21.     
  22.     
  23.         ohos:id="$+id:title"
  24.         ohos:height="match_content"
  25.         ohos:width="match_parent"
  26.         ohos:alignment="horizontal_center"
  27.         ohos:orientation="horizontal"
  28.         ohos:top_margin="35fp"
  29.         >
  30.         
  31.             ohos:height="match_content"
  32.             ohos:width="match_content"
  33.             ohos:margin="8vp"
  34.             ohos:text="HOUR"
  35.             ohos:text_size="10fp"
  36.             />
  37.         
  38.             ohos:height="match_content"
  39.             ohos:width="match_content"
  40.             ohos:margin="8vp"
  41.             ohos:text="MIN"
  42.             ohos:text_size="10fp"
  43.             />
  44.         
  45.             ohos:height="match_content"
  46.             ohos:width="match_content"
  47.             ohos:margin="8vp"
  48.             ohos:text="SEC"
  49.             ohos:text_size="10fp"
  50.             />
  51.     
  52.     
  53.         ohos:id="$+id:time"
  54.         ohos:height="match_content"
  55.         ohos:width="match_parent"
  56.         ohos:alignment="horizontal_center"
  57.         ohos:below="$id:title"
  58.         ohos:orientation="horizontal"
  59.         ohos:top_margin="0.5fp"
  60.         >
  61.         
  62.             ohos:id="$+id:hour"
  63.             ohos:height="match_content"
  64.             ohos:width="match_content"
  65.             ohos:left_margin="10vp"
  66.             ohos:right_margin="5vp"
  67.             ohos:text="00"
  68.             ohos:text_font="HwChinese-medium"
  69.             ohos:text_size="20fp"
  70.             ohos:top_margin="2vp"
  71.             />
  72.         
  73.             ohos:height="match_content"
  74.             ohos:width="match_content"
  75.             ohos:text=":"
  76.             ohos:text_font="bold"
  77.             ohos:text_size="20fp"
  78.             ohos:top_margin="2vp"
  79.             />
  80.         
  81.             ohos:id="$+id:min"
  82.             ohos:height="match_content"
  83.             ohos:width="match_content"
  84.             ohos:left_margin="5vp"
  85.             ohos:right_margin="5vp"
  86.             ohos:text="00"
  87.             ohos:text_font="HwChinese-medium"
  88.             ohos:text_size="20fp"
  89.             ohos:top_margin="2vp"
  90.             />
  91.         
  92.             ohos:height="match_content"
  93.             ohos:width="match_content"
  94.             ohos:text=":"
  95.             ohos:text_font="bold"
  96.             ohos:text_size="20fp"
  97.             ohos:top_margin="2vp"
  98.             />
  99.         
  100.             ohos:id="$+id:sec"
  101.             ohos:height="match_content"
  102.             ohos:width="match_content"
  103.             ohos:left_margin="5vp"
  104.             ohos:right_margin="10vp"
  105.             ohos:text="00"
  106.             ohos:text_font="HwChinese-medium"
  107.             ohos:text_size="20fp"
  108.             ohos:top_margin="2vp"
  109.             />
  110.     
  111.     
  112.         ohos:height="match_content"
  113.         ohos:width="match_parent"
  114.         ohos:alignment="center"
  115.         ohos:below="$id:time"
  116.         ohos:margin="16fp"
  117.         ohos:orientation="horizontal"
  118.         >
  119.         
  120.             ohos:id="$+id:sun"
  121.             ohos:height="match_content"
  122.             ohos:width="match_content"
  123.             ohos:text="日"
  124.             ohos:text_color="#C0C0C0"
  125.             ohos:text_size="10fp"
  126.             ohos:weight="1"
  127.             />
  128.         
  129.             ohos:id="$+id:mon"
  130.             ohos:height="match_content"
  131.             ohos:width="match_content"
  132.             ohos:text="一"
  133.             ohos:text_color="#C0C0C0"
  134.             ohos:text_size="10fp"
  135.             ohos:weight="1"
  136.             />
  137.         
  138.             ohos:id="$+id:tue"
  139.             ohos:height="match_content"
  140.             ohos:width="match_content"
  141.             ohos:text="二"
  142.             ohos:text_color="#C0C0C0"
  143.             ohos:text_size="10fp"
  144.             ohos:weight="1"
  145.             />
  146.         
  147.             ohos:id="$+id:wed"
  148.             ohos:height="match_content"
  149.             ohos:width="match_content"
  150.             ohos:text="三"
  151.             ohos:text_color="#C0C0C0"
  152.             ohos:text_size="10fp"
  153.             ohos:weight="1"
  154.             />
  155.         
  156.             ohos:id="$+id:thu"
  157.             ohos:height="match_content"
  158.             ohos:width="match_content"
  159.             ohos:text="四"
  160.             ohos:text_color="#C0C0C0"
  161.             ohos:text_size="10fp"
  162.             ohos:weight="1"
  163.             />
  164.         
  165.             ohos:id="$+id:fri"
  166.             ohos:height="match_content"
  167.             ohos:width="match_content"
  168.             ohos:text="五"
  169.             ohos:text_color="#C0C0C0"
  170.             ohos:text_size="10fp"
  171.             ohos:weight="1"
  172.             />
  173.         
  174.             ohos:id="$+id:sat"
  175.             ohos:height="match_content"
  176.             ohos:width="match_content"
  177.             ohos:text="六"
  178.             ohos:text_color="#C0C0C0"
  179.             ohos:text_size="10fp"
  180.             ohos:weight="1"
  181.             />
  182.     

form_image_with_info_date_card_2_4.xml #2x4規(guī)格的卡片

 
 
 
 
  1.     xmlns:ohos="http://schemas.huawei.com/res/ohos"
  2.     ohos:height="match_parent"
  3.     ohos:width="match_parent"
  4.     ohos:background_element="#FFFFFFFF"
  5.     ohos:remote="true">
  6.     
  7.         ohos:height="match_content"
  8.         ohos:width="match_parent"
  9.         ohos:orientation="horizontal"
  10.         >
  11.         
  12.             ohos:id="$+id:date"
  13.             ohos:height="match_content"
  14.             ohos:width="match_content"
  15.             ohos:align_parent_left="true"
  16.             ohos:margin="10fp"
  17.             ohos:text="2021-03-24"
  18.             ohos:text_font="sans-serif-medium"
  19.             ohos:text_size="20fp"
  20.             />
  21.         
  22.             ohos:height="match_content"
  23.             ohos:width="match_content"
  24.             ohos:align_parent_right="true"
  25.             ohos:orientation="horizontal"
  26.             ohos:top_margin="10fp"
  27.             >
  28.             
  29.                 ohos:id="$+id:sun"
  30.                 ohos:height="match_content"
  31.                 ohos:width="match_content"
  32.                 ohos:text="日"
  33.                 ohos:text_color="#C0C0C0"
  34.                 ohos:text_size="20fp"
  35.                 ohos:weight="1"
  36.                 />
  37.             
  38.                 ohos:id="$+id:mon"
  39.                 ohos:height="match_content"
  40.                 ohos:width="match_content"
  41.                 ohos:text="一"
  42.                 ohos:text_color="#C0C0C0"
  43.                 ohos:text_size="20fp"
  44.                 ohos:weight="1"
  45.                 />
  46.             
  47.                 ohos:id="$+id:tue"
  48.                 ohos:height="match_content"
  49.                 ohos:width="match_content"
  50.                 ohos:text="二"
  51.                 ohos:text_color="#C0C0C0"
  52.                 ohos:text_size="20fp"
  53.                 ohos:weight="1"
  54.                 />
  55.             
  56.                 ohos:id="$+id:wed"
  57.                 ohos:height="match_content"
  58.                 ohos:width="match_content"
  59.                 ohos:text="三"
  60.                 ohos:text_color="#C0C0C0"
  61.                 ohos:text_size="20fp"
  62.                 ohos:weight="1"
  63.                 />
  64.             
  65.                 ohos:id="$+id:thu"
  66.                 ohos:height="match_content"
  67.                 ohos:width="match_content"
  68.                 ohos:text="四"
  69.                 ohos:text_color="#C0C0C0"
  70.                 ohos:text_size="20fp"
  71.                 ohos:weight="1"
  72.                 />
  73.             
  74.                 ohos:id="$+id:fri"
  75.                 ohos:height="match_content"
  76.                 ohos:width="match_content"
  77.                 ohos:text="五"
  78.                 ohos:text_color="#C0C0C0"
  79.                 ohos:text_size="20fp"
  80.                 ohos:weight="1"
  81.                 />
  82.             
  83.                 ohos:id="$+id:sat"
  84.                 ohos:height="match_content"
  85.                 ohos:width="match_content"
  86.                 ohos:text="六"
  87.                 ohos:text_color="#C0C0C0"
  88.                 ohos:text_size="20fp"
  89.                 ohos:weight="1"
  90.                 ohos:right_margin="10fp"
  91.                 />
  92.         
  93.     
  94.     
  95.         ohos:id="$+id:title"
  96.         ohos:height="match_content"
  97.         ohos:width="match_parent"
  98.         ohos:alignment="horizontal_center"
  99.         ohos:orientation="horizontal"
  100.         ohos:top_margin="35fp"
  101.         >
  102.         
  103.             ohos:height="match_content"
  104.             ohos:width="match_content"
  105.             ohos:top_margin="20vp"
  106.             ohos:left_margin="20vp"
  107.             ohos:right_margin="20vp"
  108.             ohos:text="HOUR"
  109.             ohos:text_size="20fp"
  110.             />
  111.         
  112.             ohos:height="match_content"
  113.             ohos:width="match_content"
  114.             ohos:top_margin="20vp"
  115.             ohos:left_margin="20vp"
  116.             ohos:right_margin="20vp"
  117.             ohos:text="MIN"
  118.             ohos:text_size="20fp"
  119.             />
  120.         
  121.             ohos:height="match_content"
  122.             ohos:width="match_content"
  123.             ohos:top_margin="20vp"
  124.             ohos:left_margin="20vp"
  125.             ohos:right_margin="20vp"
  126.             ohos:text="SEC"
  127.             ohos:text_size="20fp"
  128.             />
  129.     
  130.     
  131.         ohos:id="$+id:time"
  132.         ohos:height="match_content"
  133.         ohos:width="match_parent"
  134.         ohos:alignment="horizontal_center"
  135.         ohos:below="$id:title"
  136.         ohos:orientation="horizontal"
  137.         >
  138.         
  139.             ohos:id="$+id:hour"
  140.             ohos:height="match_content"
  141.             ohos:width="match_content"
  142.             ohos:left_margin="20vp"
  143.             ohos:right_margin="10vp"
  144.             ohos:text="00"
  145.             ohos:text_font="HwChinese-medium"
  146.             ohos:text_size="40fp"
  147.             ohos:top_margin="2vp"
  148.             />
  149.         
  150.             ohos:height="match_content"
  151.             ohos:width="match_content"
  152.             ohos:text=":"
  153.             ohos:text_font="bold"
  154.             ohos:text_size="40fp"
  155.             ohos:top_margin="2vp"
  156.             />
  157.         
  158.             ohos:id="$+id:min"
  159.             ohos:height="match_content"
  160.             ohos:width="match_content"
  161.             ohos:left_margin="10vp"
  162.             ohos:right_margin="10vp"
  163.             ohos:text="00"
  164.             ohos:text_font="HwChinese-medium"
  165.             ohos:text_size="40fp"
  166.             ohos:top_margin="2vp"
  167.             />
  168.         
  169.             ohos:height="match_content"
  170.             ohos:width="match_content"
  171.             ohos:text=":"
  172.             ohos:text_font="bold"  分享標(biāo)題:HarmonyOS之時鐘FA卡片開發(fā)樣例實(shí)踐
    轉(zhuǎn)載來源:http://m.5511xx.com/article/dpddjcg.html