布局

作者: harmonyOS小飞鱼 | 来源:发表于2021-01-11 15:10 被阅读0次

1.线性布局DirectionalLayout

属性:

ohos:orientation="horizontal"//水平

下生效的对齐方式有:布局位于父布局的位置

ohos:layout_alignment="top"

ohos:layout_alignment="bottom"

ohos:layout_alignment="vertical_center"

ohos:layout_alignment="center"

//=======================================

ohos:orientation="vertical"//垂直

下生效的对齐方式有

ohos:layout_alignment="left"

ohos:layout_alignment="right"

ohos:layout_alignment="horizontal_center"

ohos:layout_alignment="center"

2.相对布局DependentLayout

每个组件可以指定相对于其他同级元素的位置,或者指定相对于父组件的位置

<?xml version="1.0" encoding="utf-8"?>

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

    ohos:height="match_parent"

    ohos:background_element="$color:aquamarine"

    ohos:width="match_parent">

        ohos:id="$+id:text1"

        ohos:height="match_content"

        ohos:width="match_parent"

        ohos:background_element="$color:red"

        ohos:element_bottom="true"

        ohos:padding="10vp"

        ohos:text="DependentLayout相对布局"

        ohos:text_alignment="horizontal_center"

        ohos:text_color="$color:white"

        ohos:text_size="25fp"

        ohos:text_style="bold"

        ohos:text_weight="1"/>

        ohos:id="$+id:text2"

        ohos:height="match_content"

        ohos:width="match_parent"

        ohos:background_element="$color:gree_home"

        ohos:below="$id:text1"

        ohos:element_bottom="true"

        ohos:padding="10vp"

        ohos:text="DependentLayout相对布局"

        ohos:text_alignment="horizontal_center"

        ohos:text_color="$color:white"

        ohos:text_size="25fp"

        ohos:text_style="bold"

        ohos:text_weight="1"/>

        ohos:id="$+id:directionalLayout"

        ohos:below="$id:text2"

        ohos:height="match_content"

        ohos:width="match_parent"

        ohos:orientation="horizontal">

            ohos:padding="10vp"

            ohos:background_element="$color:blanchedalmond"

            ohos:height="match_content"

            ohos:width="match_parent"

            ohos:text_alignment="center"

            ohos:text="测试文字03"

            ohos:id="$+id:text3"

            ohos:text_size="25fp"

            ohos:weight="1"/>

            ohos:padding="10vp"

            ohos:background_element="$color:azure"

            ohos:height="match_content"

            ohos:width="match_parent"

            ohos:text="测试文字04"

            ohos:text_alignment="center"

            ohos:text_size="25fp"

            ohos:id="$+id:text4"

            ohos:weight="1"/>

        ohos:top_margin="50"

        ohos:below="$id:directionalLayout"

        ohos:height="match_parent"

        ohos:background_element="$color:red"

        ohos:width="match_parent">

        ohos:id="$+id:text8"

        ohos:width="match_content"

        ohos:height="match_content"

        ohos:text="center_in_parent"

        ohos:text_size="12fp"

        ohos:background_element="$color:red"

        ohos:center_in_parent="1"/>

        ohos:padding="10vp"

        ohos:id="$+id:text9"

        ohos:width="match_content"

        ohos:height="match_content"

        ohos:text="align_parent_right_bottom"

        ohos:text_size="12fp"

        ohos:background_element="$color:yellow"

        ohos:align_parent_right="true"

        ohos:align_parent_bottom="true"/>

        ohos:padding="10vp"

        ohos:id="$+id:text9"

        ohos:width="match_content"

        ohos:height="match_content"

        ohos:text="align_parent_left_top"

        ohos:text_size="12fp"

        ohos:background_element="$color:yellow"

        ohos:align_parent_left="true"

        ohos:align_parent_top="true"/>

        ohos:padding="10vp"

        ohos:id="$+id:text9"

        ohos:width="match_content"

        ohos:height="match_content"

        ohos:text="align_parent_left_bottom"

        ohos:text_size="12fp"

        ohos:background_element="$color:yellow"

        ohos:align_parent_bottom="true"

        ohos:align_parent_left="true"/>

        ohos:padding="10vp"

        ohos:id="$+id:text9"

        ohos:width="match_content"

        ohos:height="match_content"

        ohos:text="align_parent_top_right"

        ohos:text_size="12fp"

        ohos:background_element="$color:yellow"

        ohos:align_parent_top="true"

        ohos:align_parent_right="true"/>

</DependentLayout>

3.层叠式布局StackLayout

4.表格布局TabLayout

相关文章

  • css经典布局总结

    布局类型 浮动布局 流式布局 定位布局 flex布局 grid布局 布局详解 1.浮动布局。 浮动布局是利用flo...

  • 布局小结

    布局方式 静态布局 浮动布局 定位布局 自适应布局 流式布局(百分比布局) 响应式布局 弹性布局 悬挂布局 圣杯布...

  • 常用的五大布局

    常用的五大布局(线性布局,相对布局,帧布局,表格布局,绝对布局) 1,线性布局 LinearLayout ...

  • 实现三栏布局的六种方式

    六种布局方式总结:圣杯布局、双飞翼布局、Flex布局、绝对定位布局、表格布局、网格布局。 圣杯布局 圣杯布局是指布...

  • CSS3开发常用核心技能

    基础网页布局 布局分类 一列布局 两列布局 三列布局 多列布局 一列布局: 二列布局: 三列布局: ⚠️ midd...

  • 移动端页面布局

    七大布局:流线布局、等比缩放拓展布局、分栏布局、流动布局、重复布局、固定布局1.流线布局流线布局指在界面中的内容元...

  • 前端网站5种布局

    前端基本布局分大致5种,table布局,float 布局,absolute布局,flexbox布局,grid布局。...

  • 2019-08-25

    布局 说法一 浮动布局 绝对定位布局 Flex布局 Table-cell表格布局 网格布局 说法二 静态布局 流式...

  • flex布局的几种典型布局方式

    flex布局的典型布局方式有哪些? 网格布局 固定底栏布局 圣杯布局 输入框布局 悬挂布局 网格布局 最简单的网格...

  • css3设计模式,常用布局

    1.css3常用的布局有多栏布局、多列布局、弹性布局、流式布局、瀑布流布局和响应式布局。2.float浮动布局,a...

网友评论

      本文标题:布局

      本文链接:https://www.haomeiwen.com/subject/nxisnktx.html