慢吞云雾缓吐愁 发表于 2024-6-11 16:23:38

搭建鸿蒙开辟环境、运行第一个鸿蒙项目、鸿蒙组件与安卓组件的简单对比 (1)

ohos:text_size=“50”
/>
<Text
ohos:height=“match_content”
ohos:width=“0vp”
ohos:weight=“1”
ohos:layout_alignment=“horizontal_center”
ohos:text_size=“50”/>
<Text
ohos:height=“match_content”
ohos:width=“match_content”
ohos:text=“text1”
ohos:background_element=“$graphic:background_ability_main”
ohos:layout_alignment=“horizontal_center”
ohos:text_size=“50”
/>
Demo
https://img-blog.csdnimg.cn/20210102221908345.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzUyNzAyODU3,size_16,color_FFFFFF,t_70#pic_center
DependentLayout
这与安卓中的约束布局相似
在这个布局中可通过两种属性来规范组件位置
相对与同级组件的位置关系属性

ohos:above:处于指定组件之上
ohos:below:处于指定组件之下
ohos:left_of:处于指定组件之左
ohos:right_of:处于指定组件之右
ohos:right_of:处于指定组件之右
ohos:start_of:处于指定组件之前
ohos:end_of:处于指定组件之后
相对与父组件的位置关系属性

ohos:align_parent_left:处于父组件左侧
ohos:align_parent_right:处于父组件右侧
ohos:align_parent_start:处于父组件开始侧
ohos:align_parent_end:处于父组件结束侧
ohos:align_parent_top:处于父组件上侧
ohos:align_parent_bottom:处于父组件下侧
ohos:center_in_parent:处于父组件中间
例子
<?xml version="1.0" encoding="utf-8"?> <DependentLayout
xmlns:ohos=“http://schemas.huawei.com/res/ohos”
ohos:height=“match_parent”
ohos:width=“match_parent”>
<Text
ohos:id=“$+id:top”
ohos:height=“match_content”
ohos:width=“match_content”
ohos:align_parent_top=“true”
ohos:center_in_parent=“true”
ohos:background_element=“$graphic:background_ability_main”
ohos:text=“top”
ohos:text_size=“50”
/>
<Text
ohos:id=“$+id:text_helloworld”
ohos:height=“match_content”
ohos:width=“match_content”
ohos:below=“$id:top”
ohos:center_in_parent=“true”
ohos:background_element=“$graphic:background_ability_main”
ohos:text=“below”
ohos:text_size=“50”
/>
<Text
ohos:id=“$+id:text_helloworld”
ohos:height=“match_content”
ohos:width=“match_content”
ohos:background_element=“$graphic:background_ability_main”
ohos:align_parent_bottom=“true”
ohos:center_in_parent=“true”
ohos:text=“bottom”
ohos:text_size=“50”
/>
Demo
https://img-blog.csdnimg.cn/20210102223512823.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzUyNzAyODU3,size_16,color_FFFFFF,t_70
StackLayout
层叠布局,在层叠布局中先创建的组件会显示在后创建组件的下层,后创建的组件会覆盖先创建的组件,如许就可以实现一种悬浮的样式,类似于悬浮按钮
在这个布局下的可以通过ohos:layout_alignment属性来规范组件位置
例子
<?xml version="1.0" encoding="utf-8"?> <StackLayout
xmlns:ohos=“http://schemas.huawei.com/res/ohos”
ohos:id=“$+id:stack_layout”
ohos:height=“match_parent”
ohos:width=“match_parent”>
<Text
ohos:id=“$+id:text_blue”
ohos:text_alignment=“bottom|horizontal_center”
ohos:text_size=“24fp”
ohos:text=“txet1”
ohos:height=“400vp”
ohos:width=“400vp”
ohos:background_element=“#40FF00” />
<Text
ohos:id=“$+id:text_light_purple”
ohos:text_alignment=“bottom|horizontal_center”
ohos:text_size=“24fp”
ohos:text=“text2”
ohos:height=“200vp”
ohos:width=“200vp”
ohos:background_element=“#2EFEF7” />
<Text
ohos:id=“$+id:text_orange”
自我先容一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里不停到现在。
深知大多数HarmonyOS鸿蒙开辟工程师,想要提升技能,往往是本身摸索发展大概是报班学习,但对于培训机构动则几千的学费,着实压力不小。本身不成体系的自学结果低效又漫长,而且极易碰到天花板技术故步自封!
因此网络整理了一份《2024年HarmonyOS鸿蒙开辟全套学习资料》,初志也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋侪,同时减轻大家的负担。
https://img-blog.csdnimg.cn/img_convert/425b305f288bf92721e2b4bf000bd99f.png
https://img-blog.csdnimg.cn/img_convert/8c26ec16265eb8bb395aa6f405b37bc5.png
https://img-blog.csdnimg.cn/img_convert/4353242a3977cb67cd953507d79592d8.png
既有恰当小白学习的零底子资料,也有恰当3年以上经验的小伙伴深入学习提升的进阶课程,根本涵盖了95%以上HarmonyOS鸿蒙开辟知识点,真正体系化!
由于文件比力大,这里只是将部门目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,而且会连续更新
如果你觉得这些内容对你有帮助,可以添加VX:vip204888 (备注鸿蒙获取)
https://img-blog.csdnimg.cn/img_convert/b74ae8baff4688ca047db5adbeda7448.png
一个人可以走的很快,但一群人才能走的更远。岂论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术互换、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习发展!
体系化!**
由于文件比力大,这里只是将部门目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,而且会连续更新
如果你觉得这些内容对你有帮助,可以添加VX:vip204888 (备注鸿蒙获取)
[外链图片转存中…(img-gHJvaQBA-1712777006392)]
一个人可以走的很快,但一群人才能走的更远。岂论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术互换、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习发展!

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: 搭建鸿蒙开辟环境、运行第一个鸿蒙项目、鸿蒙组件与安卓组件的简单对比 (1)