鴻蒙應用開發-DevEco Studio 模板體驗(一)
顯示效果:
佈局中的程式碼
<?xml version="1.0" encoding="utf-8"?> <DependentLayout xmlns:ohos=" ohos:id="$+id:ability_main" ohos:height="match_parent" ohos:width="match_parent" ohos:orientation="vertical"> <DirectionalLayout ohos:id="$+id:appBar" ohos:height="$float:height_appBar" ohos:width="match_parent" ohos:orientation="horizontal"> <DirectionalLayout ohos:id="$+id:appBar_backButton_touchTarget" ohos:height="$float:height_appBar_backButton_touchTarget" ohos:width="$float:width_appBar_backButton_touchTarget" ohos:alignment="center" ohos:left_margin="$float:leftMargin_appBar_backButton_touchTarget"> <Image ohos:id="$+id:appBar_backButton" ohos:height="$float:size_appBar_backButton" ohos:width="$float:size_appBar_backButton" ohos:image_src="$graphic:back"/> </DirectionalLayout> <Text ohos:id="$+id:appBar_title" ohos:height="match_parent" ohos:width="match_content" ohos:left_margin="$float:leftMargin_appBar_title" ohos:text="$string:title" ohos:text_size="$float:textSize_title"/> </DirectionalLayout> <ScrollView ohos:id="$+id:aboutPageScrollView" ohos:height="match_parent" ohos:width="match_parent" ohos:below="$id:appBar"> <DependentLayout ohos:id="$+id:aboutPageMain" ohos:height="match_content" ohos:width="match_parent" ohos:min_height="$float:aboutPage_minHeight" ohos:orientation="vertical"> <DirectionalLayout ohos:id="$+id:aboutPageUpperPart" ohos:height="$float:height_aboutPage_upperPart" ohos:width="match_parent" ohos:align_parent_top="true" ohos:alignment="horizontal_center" ohos:orientation="vertical"> <!-- TODO: Set the app icon here--> <Image ohos:id="$+id:aboutPageIcon" ohos:height="$float:size_aboutPage_iconBackground" ohos:width="$float:size_aboutPage_iconBackground" ohos:alignment="center" ohos:image_src="$media:icon" ohos:top_margin="$float:topMargin_aboutPage_iconBackground"/> <Text ohos:id="$+id:aboutPageTitlePrimary" ohos:height="match_content" ohos:width="match_content" ohos:text="$string:aboutPage_title_primary" ohos:text_color="$color:color_aboutPage_title_primary" ohos:text_size="$float:size_aboutPage_title_primary" ohos:top_margin="$float:topMargin_aboutPage_title_primary"/> <Text ohos:id="$+id:aboutPageTitleSecondary" ohos:height="match_content" ohos:width="match_content" ohos:text="$string:aboutPage_title_secondary" ohos:text_color="$color:color_aboutPage_title_secondary" ohos:text_size="$float:size_aboutPage_title_secondary"/> </DirectionalLayout> <DirectionalLayout ohos:id="$+id:aboutPageLowerPart" ohos:height="match_content" ohos:width="match_parent" ohos:background_element="$graphic:stacklayout_background" ohos:below="$id:aboutPageUpperPart" ohos:left_margin="$float:card_margin_start" ohos:orientation="vertical" ohos:right_margin="$float:card_margin_end"/> <DirectionalLayout ohos:id="$+id:aboutPageBottomPart" ohos:height="match_content" ohos:width="match_parent" ohos:align_parent_bottom="true" ohos:alignment="horizontal_center" ohos:below="$+id:aboutPageLowerPart" ohos:bottom_padding="$float:default_padding_bottom_fixed" ohos:left_padding="$float:maxPadding_start" ohos:orientation="vertical" ohos:right_padding="$float:maxPadding_end" ohos:top_padding="$float:default_padding_top_fixed"> <Text ohos:id="$+id:openSourceNoticeText" ohos:height="match_content" ohos:width="match_parent" ohos:layout_direction="locale" ohos:text_alignment="center" ohos:text_size="$float:textSize_body3"/> <Text ohos:id="$+id:protocolPrivacyText" ohos:height="match_content" ohos:width="match_parent" ohos:layout_direction="locale" ohos:multiple_lines="true" ohos:text_alignment="center" ohos:text_size="$float:textSize_body3"/> <Text ohos:id="$+id:copyrightText" ohos:height="match_content" ohos:width="match_parent" ohos:layout_direction="locale" ohos:text="$string:copyright_text" ohos:text_alignment="center" ohos:text_color="$color:textColor_secondary" ohos:text_size="$float:textSize_body3"/> <Text ohos:id="$+id:technicalSupportText" ohos:height="match_content" ohos:width="match_parent" ohos:layout_direction="locale" ohos:text="$string:technicalSupport_text" ohos:text_alignment="center" ohos:text_color="$color:textColor_secondary" ohos:text_size="$float:textSize_body3"/> </DirectionalLayout> </DependentLayout> </ScrollView> </DependentLayout>
顯示效果:
佈局中的程式碼
<?xml version="1.0" encoding="utf-8"?> <DependentLayout xmlns:ohos=" ohos:id="$+id:root_layout" ohos:height="match_parent" ohos:width="match_parent" ohos:orientation="vertical"> <DirectionalLayout ohos:id="$+id:background" ohos:height="match_parent" ohos:width="match_parent" ohos:align_parent_top="true" ohos:background_element="$color:color_background"/> <DirectionalLayout ohos:id="$+id:appBar" ohos:height="match_content" ohos:width="match_parent" ohos:align_parent_top="true" ohos:end_padding="$float:max_padding_appBar" ohos:layout_direction="locale" ohos:orientation="horizontal" ohos:start_padding="$float:max_padding_start"> <DirectionalLayout ohos:id="$+id:appBar_leftPart" ohos:height="$float:height_backButton_touchTarget" ohos:width="0vp" ohos:alignment="center" ohos:orientation="horizontal" ohos:weight="1"> <Image ohos:id="$+id:appBar_backButton" ohos:height="$float:height_appBar_Buttons" ohos:width="$float:width_appBar_buttons" ohos:image_src="$graphic:ic_back"/> <Text ohos:id="$+id:appBar_userName" ohos:height="match_parent" ohos:width="match_parent" ohos:alpha="0" ohos:left_margin="$float:leftMargin_userName" ohos:text="$string:title_contactsDetail" ohos:text_size="$float:textSize_userName"/> </DirectionalLayout> <DirectionalLayout ohos:id="$+id:appBar_rightPart" ohos:height="match_parent" ohos:width="0vp" ohos:alignment="vertical_center|right" ohos:orientation="horizontal" ohos:start_margin="$float:start_margin_appBar" ohos:weight="1"> <DirectionalLayout ohos:id="$+id:appBar_button1_touchTarget" ohos:height="$float:height_touchTarget" ohos:width="$float:width_touchTarget" ohos:alignment="center"> <Image ohos:id="$+id:appBar_button1" ohos:height="$float:height_appBar_Buttons" ohos:width="$float:width_appBar_buttons" ohos:image_src="$graphic:ic_add"/> </DirectionalLayout> <DirectionalLayout ohos:id="$+id:appBar_button2_touchTarget" ohos:height="$float:height_touchTarget" ohos:width="$float:width_touchTarget" ohos:alignment="center"> <Image ohos:id="$+id:appBar_button2" ohos:height="$float:height_appBar_Buttons" ohos:width="$float:width_appBar_buttons" ohos:image_src="$graphic:ic_add"/> </DirectionalLayout> <DirectionalLayout ohos:id="$+id:appBar_button3_touchTarget" ohos:height="$float:height_touchTarget" ohos:width="$float:width_touchTarget" ohos:alignment="center"> <Image ohos:id="$+id:appBar_button3" ohos:height="$float:height_appBar_Buttons" ohos:width="$float:width_appBar_buttons" ohos:image_src="$graphic:ic_more"/> </DirectionalLayout> </DirectionalLayout> </DirectionalLayout> <ScrollView ohos:id="$+id:contacts_detail_scroll" ohos:height="match_parent" ohos:width="match_parent" ohos:below="$id:appBar" ohos:bottom_margin="$float:height_bottom_tab"> <DependentLayout ohos:id="$+id:contacts_detail" ohos:height="match_content" ohos:width="match_parent" ohos:orientation="vertical"> <DependentLayout ohos:id="$+id:contacts_detail_upperCard" ohos:height="match_content" ohos:width="match_parent" ohos:align_parent_top="true" ohos:background_element="$graphic:card_background" ohos:left_padding="$float:max_padding_start" ohos:orientation="vertical" ohos:right_padding="$float:max_padding_end" ohos:top_margin="$float:topMargin_contactsDetail_upperCard"> <ListContainer ohos:id="$+id:contacts_detail_upperCard_list" ohos:height="0vp" ohos:width="match_parent" ohos:below="$+id:contacts_detail_title"/> <Text ohos:id="$+id:contacts_detail_title" ohos:height="match_content" ohos:width="match_parent" ohos:align_parent_top="true" ohos:text="$string:title_contactsDetail" ohos:text_alignment="horizontal_center" ohos:text_size="$float:textSize_contactsDetail_title" ohos:top_margin="$float:topMargin_contactsDetail_title"/> </DependentLayout> <Image ohos:id="$+id:contacts_detail_profile" ohos:height="$float:height_contacts_profile" ohos:width="$float:width_contacts_profile" ohos:align_parent_top="true" ohos:alpha="1" ohos:background_element="$media:profile" ohos:center_in_parent="true" ohos:top_margin="$float:topMargin_contacts_profile"/> </DependentLayout> </ScrollView> <DirectionalLayout ohos:id="$+id:bottom_tab" ohos:height="$float:height_bottom_tab" ohos:width="match_parent" ohos:align_parent_bottom="true" ohos:alignment="vertical_center" ohos:background_element="$graphic:bottom_tab_background" ohos:left_padding="$float:max_padding_start" ohos:right_padding="$float:max_padding_end"> <DirectionalLayout ohos:id="$+id:bottom_tabMenu" ohos:height="match_content" ohos:width="match_parent" ohos:orientation="horizontal"/> </DirectionalLayout> </DependentLayout>
顯示效果:
可以上下滑動檢視
佈局中的程式碼
<?xml version="1.0" encoding="utf-8"?> <DirectionalLayout xmlns:ohos=" ohos:height="match_parent" ohos:width="match_parent" ohos:background_element="$color:colorAppBackground" ohos:orientation="vertical"> <!-- Title part--> <DirectionalLayout xmlns:ohos=" ohos:height="$float:titlePartHeight" ohos:width="match_parent" ohos:background_element="$color:colorAppBackground" ohos:orientation="vertical"> <DependentLayout xmlns:ohos=" ohos:height="$float:titlePartIconDivHeight" ohos:width="match_parent"> <DependentLayout xmlns:ohos=" ohos:id="$+id:title_area_menu" ohos:height="$float:titlePartIconHotAreaHeight" ohos:width="$float:titlePartIconHotAreaWidth" ohos:align_parent_right="true" ohos:center_in_parent="true" ohos:right_margin="$float:titlePartIconHotAreaRightMargin"> <Image ohos:id="$+id:title_area_menu_icon" ohos:height="$float:titlePartIconHeight" ohos:width="$float:titlePartIconWidth" ohos:center_in_parent="true" ohos:image_src="$graphic:icon_more"/> </DependentLayout> <DependentLayout xmlns:ohos=" ohos:id="$+id:title_area_add" ohos:height="$float:titlePartIconHotAreaHeight" ohos:width="$float:titlePartIconHotAreaWidth" ohos:center_in_parent="true" ohos:left_of="$id:title_area_menu"> <Image ohos:id="$+id:title_area_add_icon" ohos:height="$float:titlePartIconHeight" ohos:width="$float:titlePartIconWidth" ohos:center_in_parent="true" ohos:image_src="$graphic:icon_add"/> </DependentLayout> <DependentLayout xmlns:ohos=" ohos:id="$+id:title_area_add1" ohos:height="$float:titlePartIconHotAreaHeight" ohos:width="$float:titlePartIconHotAreaWidth" ohos:center_in_parent="true" ohos:left_of="$id:title_area_add"> <Image ohos:id="$+id:title_area_add_icon1" ohos:height="$float:titlePartIconHeight" ohos:width="$float:titlePartIconWidth" ohos:center_in_parent="true" ohos:image_src="$graphic:icon_add"/> </DependentLayout> </DependentLayout> <Text ohos:id="$+id:title_text" ohos:height="$float:titlePartTextAreaHeight" ohos:width="match_parent" ohos:bottom_margin="$float:titlePartTextAreaBottomMargin" ohos:left_margin="$float:titlePartTextAreaLeftMargin" ohos:right_margin="$float:titlePartTextAreaRightMargin" ohos:text="$string:title_text" ohos:text_alignment="vertical_center" ohos:text_color="$color:colorAppbarTitle" ohos:text_font="medium" ohos:text_size="$float:textSizeHeadline6" ohos:top_margin="$float:titlePartTextAreaTopMargin"/> </DirectionalLayout> <ListContainer ohos:id="$+id:list_view" ohos:height="match_content" ohos:width="match_parent" ohos:bottom_padding="$float:listContainerBottomPadding" ohos:left_margin="$float:singleCardViewLeftMargin" ohos:right_margin="$float:singleCardViewRightMargin"/> </DirectionalLayout>
完整程式碼地址:
原文連結: https://developer.huawei.com/consumer/cn/forum/topic/0202547249502320070?fid=0101303901040230869
原作者: 蛟龍騰飛
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69970551/viewspace-2771484/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 鴻蒙應用開發-DevEco Studio 模板體驗(四)鴻蒙dev
- 鴻蒙應用開發-DevEco Studio 模板體驗(三)鴻蒙dev
- DevEco Studio 2.0開發鴻蒙HarmonyOS應用初體驗全面測評dev鴻蒙
- 使用Taro開發鴻蒙原生應用——快速上手,鴻蒙應用開發指南鴻蒙
- 使用 Taro 開發鴻蒙原生應用 —— 快速上手,鴻蒙應用開發指南鴻蒙
- 鴻蒙 HAIWEI DevEco Studio 安裝配置,執行Hello World!鴻蒙AIdev
- 鴻蒙OS 2.0應用開發初潮鴻蒙
- 【鴻蒙千帆起】《開心消消樂》完成鴻蒙原生應用開發,創新多端聯動使用者體驗鴻蒙
- 鴻蒙系統應用基礎開發鴻蒙
- 鴻蒙系統應用開發之開發準備鴻蒙
- 鴻蒙 Android iOS 應用開發對比02鴻蒙AndroidiOS
- 鴻蒙真的是套殼嗎?HarmonyOS應用開發初體驗,Java原生和JavaScript的mvvm開發鴻蒙JavaScriptMVVM
- 加速鴻蒙生態共建,螞蟻mPaaS助力鴻蒙原生應用開發創新鴻蒙
- 鴻蒙應用開發新體驗——論大廠產業規劃與就業趨勢鴻蒙產業就業
- 鴻蒙原生應用開發——分散式資料物件鴻蒙分散式物件
- 自學鴻蒙應用開發(17)- TabList和Tab鴻蒙
- 優酷鴻蒙開發實踐 | 鴻蒙卡片開發鴻蒙
- 《三國殺》完成鴻蒙原生應用開發,更多遊戲品類加入鴻蒙生態鴻蒙遊戲
- 鴻蒙系統應用開發之入門解說鴻蒙
- 《保衛蘿蔔4》僅用一個月完成鴻蒙原生應用開發鴻蒙
- 雷霆遊戲加入鴻蒙“朋友圈”,《問道》手遊啟動鴻蒙原生應用開發遊戲鴻蒙
- 如何使用DevEco Studio建立Native C++應用devC++
- 米哈遊宣佈啟動鴻蒙原生應用開發鴻蒙
- 鴻蒙IDE的家居裝置控制模板使用經驗鴻蒙IDE
- 一、鴻蒙開發-ArkTS快速入門鴻蒙
- 鴻蒙開發學習(一)之ArkTS鴻蒙
- 鴻蒙系統應用開發之JS實現一個簡單的List鴻蒙JS
- 鴻蒙開發案例:直尺鴻蒙
- 鴻蒙JS 開發整理鴻蒙JS
- 軟通動力鴻蒙書籍《HarmonyOS應用開發》正式出版鴻蒙
- 鴻蒙作業系統開發工具DevEco下載和安裝(圖文詳細教程)鴻蒙作業系統dev
- 鴻蒙原生應用開發及部署:開啟HarmonyOS NEXT App新紀元鴻蒙APP
- 如何快速開發一個鴻蒙原生app鴻蒙APP
- 鴻蒙生態夥伴SDK市場正式釋出,驅動千行百業鴻蒙原生應用開發鴻蒙
- 鴻蒙系統應用開發之基於API6的藍芽開發鴻蒙API藍芽
- 鷹角網路宣佈將啟動鴻蒙原生應用開發鴻蒙
- 鴻蒙開發案例:指南針鴻蒙
- 鴻蒙3D開發鴻蒙3D