鸿蒙应用开发系列课答案,鸿蒙应用开发-DevEco Studio 模板体验(三)

本文详细介绍了HarmonyOS中设置页面框架和商品展示的代码实现,包括元素尺寸、对齐方式、内容布局等关键要素。通过解析XML布局文件,展示了如何创建卡片视图、界面跳转及商品展示的组件和样式设定,为HarmonyOS应用开发提供了参考。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

设置页面框架:

1460000039985303

1460000039985304

部分代码如下:

xmlns:ohos="http://schemas.huawei.com/res/ohos"

ohos:height="$float:singleCardViewHeight"

ohos:width="match_parent">

ohos:id="$+id:item_content_text"

ohos:height="$float:singleCardViewTextHeight"

ohos:width="match_content"

ohos:align_parent_left="true"

ohos:center_in_parent="true"

ohos:left_margin="$float:singleCardViewLeftMargin"

ohos:text_color="$color:textColorPrimary"

ohos:text_size="$float:textSizeBody1"/>

ohos:id="$+id:item_right_icon"

ohos:height="match_content"

ohos:width="match_content"

ohos:align_parent_right="true"

ohos:center_in_parent="true"

ohos:image_src="$graphic:icon_right_grey"

ohos:right_margin="$float:singleCardViewRightMargin"/>

ohos:id="$+id:item_right_content_text"

ohos:height="$float:singleCardViewRightTextHeight"

ohos:width="match_content"

ohos:center_in_parent="true"

ohos:left_of="$id:item_right_icon"

ohos:right_margin="$float:singleCardViewRightTextRightMargin"

ohos:text_color="$color:textColorSecondary"

ohos:text_size="$float:textSizeBody2"/>

页面滞留界面跳转

1460000039985305

1460000039985306

部分代码如下:

xmlns:ohos="http://schemas.huawei.com/res/ohos"

ohos:height="match_content"

ohos:width="match_parent"

ohos:bottom_margin="$float:margin_common"

ohos:left_margin="$float:breadth_common"

ohos:orientation="horizontal"

ohos:right_margin="$float:breadth_common"

ohos:top_margin="$float:margin_common">

ohos:height="match_parent"

ohos:width="match_content"

ohos:left_padding="$float:breadth_common"

ohos:orientation="horizontal"

ohos:weight="1">

ohos:id="$+id:item_icon"

ohos:height="$float:breadth_checkbox_image"

ohos:width="$float:breadth_checkbox_image"

ohos:layout_alignment="vertical_center"

ohos:left_margin="$float:margin_checkbox_image"

ohos:right_margin="$float:breadth_checkbox_image_margin"/>

ohos:id="$+id:text_layout"

ohos:height="match_content"

ohos:width="match_content"

ohos:orientation="vertical">

ohos:id="$+id:item_content_text"

ohos:height="match_content"

ohos:width="match_content"

ohos:layout_alignment="left"

ohos:text_size="$float:checkbox_main_text_size"/>

ohos:id="$+id:item_status_text"

ohos:height="match_content"

ohos:width="match_content"

ohos:layout_alignment="left"

ohos:multiple_lines="true"

ohos:text_size="$float:checkbox_minor_text_size"

ohos:top_margin="$float:margin_between_texts"

/>

xmlns:ohos="http://schemas.huawei.com/res/ohos"

ohos:id="$+id:checkbox_layout"

ohos:height="$float:height_checkbox_1"

ohos:width="match_content"

ohos:bottom_margin="$float:margin_common"

ohos:layout_alignment="right"

ohos:orientation="horizontal"

ohos:right_margin="$float:breadth_checkbox"

ohos:top_margin="$float:margin_common">

ohos:id="$+id:item_right_checkbox"

ohos:height="$float:height_checkbox_image"

ohos:width="$float:width_checkbox_image"

ohos:bottom_margin="$float:margin_common2"

ohos:image_src="$media:Enabled"

ohos:layout_alignment="vertical_center"

ohos:top_margin="$float:margin_common2"

/>

商品框架:

1460000039985307

1460000039985308

1460000039985309

部分代码:

xmlns:ohos="http://schemas.huawei.com/res/ohos"

ohos:height="match_content"

ohos:width="match_parent"

ohos:bottom_margin="$float:margin_common"

ohos:left_margin="$float:breadth_common"

ohos:orientation="horizontal"

ohos:right_margin="$float:breadth_common"

ohos:top_margin="$float:margin_common">

ohos:height="match_parent"

ohos:width="match_content"

ohos:left_padding="$float:breadth_common"

ohos:orientation="horizontal"

ohos:weight="1">

ohos:id="$+id:item_icon"

ohos:height="$float:breadth_checkbox_image"

ohos:width="$float:breadth_checkbox_image"

ohos:layout_alignment="vertical_center"

ohos:left_margin="$float:margin_checkbox_image"

ohos:right_margin="$float:breadth_checkbox_image_margin"/>

ohos:id="$+id:text_layout"

ohos:height="match_content"

ohos:width="match_content"

ohos:orientation="vertical">

ohos:id="$+id:item_content_text"

ohos:height="match_content"

ohos:width="match_content"

ohos:layout_alignment="left"

ohos:text_size="$float:checkbox_main_text_size"/>

ohos:id="$+id:item_status_text"

ohos:height="match_content"

ohos:width="match_content"

ohos:layout_alignment="left"

ohos:multiple_lines="true"

ohos:text_size="$float:checkbox_minor_text_size"

ohos:top_margin="$float:margin_between_texts"

/>

xmlns:ohos="http://schemas.huawei.com/res/ohos"

ohos:id="$+id:checkbox_layout"

ohos:height="$float:height_checkbox_1"

ohos:width="match_content"

ohos:bottom_margin="$float:margin_common"

ohos:layout_alignment="right"

ohos:orientation="horizontal"

ohos:right_margin="$float:breadth_checkbox"

ohos:top_margin="$float:margin_common">

ohos:id="$+id:item_right_checkbox"

ohos:height="$float:height_checkbox_image"

ohos:width="$float:width_checkbox_image"

ohos:bottom_margin="$float:margin_common2"

ohos:image_src="$media:Enabled"

ohos:layout_alignment="vertical_center"

ohos:top_margin="$float:margin_common2"

/>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值