安卓APP(3)——安卓布局控件

article/2025/9/28 0:22:20

嵌入式之路,贵在日常点滴

                                                                ---阿杰在线送代码

目录

一、布局的种类 

二、布局和页面的关系

三、显示一张美女图 

控件的宽度和高度

四、布局背景颜色,背景图,显示两个美女

关于控件ID

五、常用布局之相对布局

RelativeLayout中子控件常用属性

关于控件ID使用注意点 

六、 基础控件之Button,TextView,EditText,ImageView

控件布局

通过拖拽

通过代码编写 

七、padding和margin

内边距padding

外边距margin

八、做出一个智能家居布局图(新大陆2016年物联网国赛题目)

Android圆角按键的实现 

九、常用布局之线性布局

LinearLayout(线性布局)常用到的属性简单归纳一下:

layout_weight(权重)

divider分割线 

用线性布局来做一个登录界面

其他:必备快捷键


下面涉及到两个主要的文件类型:

.xml负责页面布局效果,.java负责后台逻辑。

一、布局的种类 

二、布局和页面的关系

运行结果:#ff0000红

整体框架

<RelativeLayout  > //父布局

            //往该布局添加控件

            <TextView />

            <Button/>

</RelativeLayout>

三、显示一张美女图 

控件的宽度和高度

控件的宽度           

           android:layout_width="match_parent"

                fill_parent和match_parent  都是大小跟父控件对齐

                wrap_content    该控件有多大就显示多大

控件的高度

            android:layout_height="match_parent"

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/bg"tools:context=".MainActivity" ></RelativeLayout>

运行结果:

  

每个框架都有这三句话 

四、布局背景颜色,背景图,显示两个美女

关于控件ID

给控件起一个ID:

               android:id="@+id/girl1"

让一个控件和跟其他控件起联系,比如放它下面(就利用到这个ID):

               android:layout_below="@id/girl1"

运行结果:

  

一个大布局底下有两个小布局

  

五、常用布局之相对布局

RelativeLayout中子控件常用属性

1、相对于父控件,例如:android:layout_alignParentTop=“true”

android:layout_alignParentTop      控件的顶部与父控件的顶部对齐;

android:layout_alignParentBottom  控件的底部与父控件的底部对齐;

android:layout_alignParentLeft      控件的左部与父控件的左部对齐;

android:layout_alignParentRight     控件的右部与父控件的右部对齐;

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><RelativeLayout android:id="@+id/girl2"android:layout_alignParentBottom="true"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/testpic32"        ></RelativeLayout></RelativeLayout>

运行结果:

  

2、相对给定Id控件,例如:android:layout_above=“@id/**”

android:layout_above 控件的底部置于给定ID的控件之上;

android:layout_below     控件的底部置于给定ID的控件之下;

android:layout_toLeftOf    控件的右边缘与给定ID的控件左边缘对齐;

android:layout_toRightOf  控件的左边缘与给定ID的控件右边缘对齐;

android:layout_alignBaseline  控件的baseline与给定ID的baseline对齐;(少用)

android:layout_alignTop        控件的顶部边缘与给定ID的顶部边缘对齐;

android:layout_alignBottom   控件的底部边缘与给定ID的底部边缘对齐;

android:layout_alignLeft       控件的左边缘与给定ID的左边缘对齐;

android:layout_alignRight      控件的右边缘与给定ID的右边缘对齐;

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><RelativeLayout android:id="@+id/girl2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/testpic32"        ></RelativeLayout><RelativeLayout android:id="@+id/girl1"android:layout_toRightOf="@id/girl2"android:layout_alignBottom="@id/girl2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/testpic"        ></RelativeLayout>   </RelativeLayout>

运行结果:

  

关于控件ID使用注意点 

3、居中,例如:android:layout_centerInParent=“true”

android:layout_centerHorizontal 水平居中;

android:layout_centerVertical    垂直居中;

android:layout_centerInParent  父控件的中央; 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><RelativeLayout android:id="@+id/girl1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/testpic"  android:layout_centerInParent="true"      ></RelativeLayout>   </RelativeLayout>

运行结果:

六、 基础控件之Button,TextView,EditText,ImageView

Button:按键

TextView:文本框

EditText:编辑文本

ImageView:图片框

控件布局

通过拖拽

通过代码编写 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:paddingBottom="@dimen/activity_vertical_margin"android:paddingLeft="@dimen/activity_horizontal_margin"android:paddingRight="@dimen/activity_horizontal_margin"android:paddingTop="@dimen/activity_vertical_margin"tools:context=".MainActivity" ><RelativeLayoutandroid:layout_width="400dp"android:layout_height="150dp"android:layout_centerInParent="true"android:background="#ff0000" ><TextViewandroid:id="@+id/user"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:layout_marginRight="10dp"android:layout_marginTop="10dp"android:text="用户"android:textColor="#ffffff"android:textSize="20dp" /><EditTextandroid:id="@+id/ed1"android:layout_width="320dp"android:layout_height="40dp"android:layout_toRightOf="@id/user" /><TextViewandroid:id="@+id/passwd"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@id/user"android:layout_marginLeft="20dp"android:layout_marginRight="10dp"android:layout_marginTop="20dp"android:text="密码"android:textColor="#ffffff"android:textSize="20dp" /><EditTextandroid:id="@+id/ed2"android:layout_width="320dp"android:layout_height="40dp"android:layout_below="@id/ed1"android:layout_toRightOf="@id/user" /><Buttonandroid:id="@+id/btn2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_below="@id/ed2"android:layout_marginRight="20dp"android:text="取消" /><Buttonandroid:id="@+id/btn1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@id/ed2"android:layout_marginRight="30dp"android:layout_toLeftOf="@id/btn2"android:text="确定" /></RelativeLayout></RelativeLayout>

运行结果:

技巧总结:像这种边框有确认和取消两个按键的,先确定好靠近右布局边框的按键,比较好做。  

七、padding和margin

内边距padding

默认情况下,组件相互之间是紧紧靠在一起的。但是有时候需要组件各边之间有一定的内边距,那就可以通过以下几个属性来设置,内边距的值是具体的尺寸,如5dp。

  • android:padding:为组件的四边设置相同的内边距。

  • android:paddingLeft:为组件的左边设置内边距。

  • android:paddingRight:为组件的右边设置内边距。

  • android:paddingTop:为组件的上边设置内边距。

  • android:paddingBottom:为组件的下边设置内边距。

内边距的原理如下图所示:

在六的例子进行举例子:

        <Buttonandroid:id="@+id/btn1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:paddingRight="100dp"android:layout_below="@id/ed2"android:layout_marginRight="30dp"android:layout_toLeftOf="@id/btn2"android:text="确定" />

运行结果:

  

外边距margin

通过设置内边距,只能设置内容相对于组件之间的距离,而组件之间仍然是相邻挨着的。在实际开发中,有时候需要组件之间有一定的间隔距离,那么就需要用到外边距了,可以通过以下几个属性来设置。

  • android:layout_margin:本组件离上下左右各组件的外边距。

  • android:layout_marginStart:本组件离开始的位置的外边距。

  • android:layout_marginEnd:本组件离结束位置的外边距。

  • android:layout_marginBottom:本组件离下部组件的外边距。

  • android:layout_marginTop:本组件离上部组件的外边距。

  • android:layout_marginLeft:本组件离左部组件的外边距。

  • android:layout_marginRight:本组件离右部组件的外边距。

外边距的原理如下图所示:

        <Buttonandroid:id="@+id/btn1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@id/ed2"android:layout_marginRight="100dp"android:layout_toLeftOf="@id/btn2"android:text="确定" />

运行结果:

  

八、做出一个智能家居布局图(新大陆2016年物联网国赛题目)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/bg_shopping_menu"tools:context=".MainActivity" ><RelativeLayout android:layout_width="match_parent"android:layout_height="wrap_content"android:background="#00ff00"><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="阿杰智能家居"android:textSize="25dp"android:layout_marginLeft="15dp"android:layout_marginTop="6dp"/><Button android:id="@+id/zhuce"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="注册"android:layout_alignParentRight="true"android:layout_marginRight="20dp"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="查询信息"android:layout_toLeftOf="@id/zhuce"/></RelativeLayout><ImageView android:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/pic_rf"android:layout_centerInParent="true"/><ImageView android:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/card"android:layout_centerInParent="true"android:paddingLeft="120dp"  /><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/btn_selector"android:text="刷卡"android:layout_marginBottom="30dp"android:layout_centerHorizontal="true"android:layout_alignParentBottom="true"/></RelativeLayout>

运行结果:

Android圆角按键的实现 

res->drawable-mdpi->右键-> Android->Android XML File->起个名称xxx.xml

  

1、在res/drawable目录下新建按钮样式文件 btn_normal.xml(正常状态) 和 btn_pressed.xml(按下状态)。

btn_normal.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<shapexmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><!-- 圆角的半径 --><corners android:radius="10dp"/><!-- 填充颜色 --><solid android:color="#3a8fea"/></shape>

btn_pressed.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><!-- 圆角的半径 --><corners android:radius="10dp"/><!-- 填充颜色 --><solid android:color="#0662f5"/></shape>

2、在res/drawable目录下新建样式文件 btn_selector.xml 文件,定义按钮的不同状态样式。

btn_selector.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"><!-- 正常状态 --><item android:drawable="@drawable/btn_normal" android:state_pressed="false"/><!-- 按下状态 --><item android:drawable="@drawable/btn_pressed" android:state_pressed="true"/></selector>

  

3、使用按钮样式 

activity_main.xml

android:background="@drawable/btn_selector"

 

九、常用布局之线性布局

LinearLayout又称作线性布局,是一种非常常用的布局。

这个布局会将它所包含的控件在线性方向上依次排列。

既然是线性排列,肯定就不仅只有一个方向,这里一般只有两个方向:水平方向和垂直方向。

LinearLayout(线性布局)常用到的属性简单归纳一下:

属性名解释
android:orientation指定线性布局的方向(水平或者垂直)
android:width线性布局的容器宽度
android:height线性布局的容器高度
android:background线性布局的背景
android:gravity线性布局中,子容器相对于父容器所在的位置
android:layout_gravity容器相对它的父元素的对齐方式
android:layout_weight权重,按比例来分配控件占用父控件的大小

orientation

属性值解释
android:orientation=“horizontal”指定线性布局方向:水平
android:orientation=“vertical”指定线性布局方向:垂直

width

属性值解释
android:width=“xxxdp”指定线性布局的容器宽度为:xxxdp
android:width=“wrap_content”指定线性布局的容器宽度为:根据容器内容宽度大小来填充屏幕宽度
android:width=“match_parent”指定线性布局的容器宽度为:撑满整个屏幕宽度

height

属性值解释
android:height=“xxxdp”指定线性布局的容器高度为:xxxdp
android:height=“wrap_content”指定线性布局的容器高度为:根据容器内容高度大小来填充屏幕高度
android:height=“match_parent”指定线性布局的容器高度为:撑满整个屏幕高度

background 

属性值解释
android:background="#000"指定线性布局的背景为:黑色(rgb颜色)
android:background="@android:color/black"指定线性布局的背景为:黑色(引用android系统自带的原始黑色)
andrid:background="@color/colorPrimary"指定线性布局的背景为:(根据res/color.xml 中的colorPrimary所定义的颜色设置)

gravity

自身是父容器

属性值解释
android:gravity=“center”指定线性布局中,子容器相对于父容器所在的位置为:正中心
android:gravity=“cente_verticalr”指定线性布局中,子容器相对于父容器所在的位置为:垂直方向的正中心
android:gravity=“center_horizontal”指定线性布局中,子容器相对于父容器所在的位置为:水平方向的正中心
android:gravity=“left”指定线性布局中,子容器相对于父容器所在的位置为:最左边(默认)
android:gravity=“right”指定线性布局中,子容器相对于父容器所在的位置为:最右边
android:gravity=“top”指定线性布局中,子容器相对于父容器所在的位置为:最上方(默认)
android:gravity=“bottom”指定线性布局中,子容器相对于父容器所在的位置为:最下方
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><LinearLayoutandroid:layout_width="match_parent"android:layout_height="70dp"android:layout_centerInParent="true"android:background="#ff0000"android:orientation="horizontal" ><LinearLayoutandroid:layout_width="0dp"android:layout_height="70dp"android:layout_weight="1"android:orientation="vertical"android:background="#00ff00" >            <TextViewandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:gravity="center"android:text="账号" /><TextViewandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:gravity="center"android:text="密码" /></LinearLayout><LinearLayoutandroid:layout_width="0dp"android:layout_height="70dp"android:layout_weight="5"android:background="#0000ff" ></LinearLayout></LinearLayout></RelativeLayout>

运行结果:

  

layout_gravity

自身是子容器

属性值解释
android:gravity=“center”指定线性布局中,子容器相对于父容器所在的位置为:正中心
android:gravity=“cente_verticalr”指定线性布局中,子容器相对于父容器所在的位置为:垂直方向的正中心
android:gravity=“center_horizontal”指定线性布局中,子容器相对于父容器所在的位置为:水平方向的正中心
android:gravity=“left”指定线性布局中,子容器相对于父容器所在的位置为:最左边(默认)
android:gravity=“right”指定线性布局中,子容器相对于父容器所在的位置为:最右边
android:gravity=“top”指定线性布局中,子容器相对于父容器所在的位置为:最上方(默认)
android:gravity=“bottom”指定线性布局中,子容器相对于父容器所在的位置为:最下方

layout_weight(权重)

当我们给一个view设置了android:layout_weight属性,意味着赋予它话语权,常规思维就是谁的weight大,谁说了算(空间占比大)。

属性值解释
android:layout_weight=“2”该单元权重为2
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><LinearLayout android:layout_width="match_parent"android:layout_height="70dp"android:background="#ff0000"android:layout_centerInParent="true" android:orientation="horizontal"                   ><LinearLayout android:layout_weight="1"android:layout_width="0dp"android:layout_height="70dp"android:background="#00ff00"></LinearLayout><LinearLayout android:layout_weight="5"android:layout_width="0dp"android:layout_height="70dp"android:background="#0000ff"></LinearLayout></LinearLayout></RelativeLayout>

运行结果:

注意点:

  

divider分割线 

fenge.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"><size android:width="200dp"android:height="2dp"/><stroke android:color="#000000"/></shape>

  

            android:divider="@drawable/fenge"android:dividerPadding="2dp"android:showDividers="middle|end"

例子

        <LinearLayoutandroid:layout_width="0dp"android:layout_height="100dp"android:layout_weight="1"android:divider="@drawable/fenge"android:dividerPadding="2dp"android:showDividers="middle|end"android:orientation="vertical" >

用线性布局来做一个登录界面

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/bg_shopping_menu"tools:context=".MainActivity" ><LinearLayoutandroid:layout_width="400dp"android:layout_height="100dp"android:layout_centerInParent="true"android:orientation="horizontal" ><LinearLayoutandroid:layout_width="0dp"android:layout_height="100dp"android:layout_weight="1"android:orientation="vertical" ><TextViewandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:gravity="center"android:text="账号" /><TextViewandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:gravity="center"android:text="密码" /><TextViewandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:gravity="center"android:text="ID号" /></LinearLayout><LinearLayoutandroid:layout_width="0dp"android:layout_height="100dp"android:layout_weight="5"android:orientation="vertical" ><EditTextandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1" /><EditTextandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1" /><EditTextandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1" /></LinearLayout></LinearLayout></RelativeLayout>

运行结果:

  

其他:必备快捷键

Ctrl +shift+ /
注释光标所在行代码,会根据当前不同文件类型使用不同的注释符号

Ctrl + Alt + L
格式化代码,可以对当前文件和整个包目录使用

Ctrl + R
在当前文件进行文本替换

Ctrl + Y
删除光标所在行 或 删除选中的行
alt+左/右方向键
回到上一个/下一个位置

想使用自动补全时,最快的办法是跳着输入字母。
比如你想快速输入android:layout_width,就直接打wi等等,打几个关键字然后Alt+/自动补全.
 


http://chatgpt.dhexx.cn/article/mfdYler0.shtml

相关文章

安卓的相对布局与线性布局

一、安卓布局的种类 Android共有七大基本布局。 分别是&#xff1a;线性布局LinearLayout、表格布局TableLayout、相对布局RelativeLayout、帧布局FrameLayout、绝对布局AbsoluteLayout、网格布局GridLayout。约束布局ConstraintLayout。 其中&#xff0c;表格布局是线性布局的…

Android:布局

Android&#xff1a;布局 LinearLayoutRelativeLayoutFrameLayoutTableLayoutGridLayoutConstraintLayout LinearLayout <LinearLayout xmlns:android"http://schemas.android.com/apk/res/android"android:layout_height"match_parent"android:layout_…

安卓六大布局之 线性布局(LinearLayout)

Android的界面是有布局和组件协同完成的&#xff0c;布局好比是建筑里的框架&#xff0c;而组件则相当于建筑里的砖瓦。组件按照布局的要求依次排列&#xff0c;就组成了用户所看见的界面。 Android的六大布局分别是 LinearLayout&#xff08;线性布局&#xff09;RelativeLayo…

Android-布局管理器

线性布局(Linearlayout) 属性 orientation 布局管理器内组件的排列方式(horizontal&#xff08;水平&#xff09;和vertical&#xff08;垂直&#xff09;&#xff0c;默认值为 horizontal.) layout_weight 权重 用于设置组件占父容器剩余空间的比例 la…

android 布局

android学习笔记&#xff08;一 android布局学习&#xff09; 转自http://blog.sina.com.cn/s/blog_61c62a960100ev3q.html (2009-09-20 20:50:44) 转载 标签&#xff1a; it 分类&#xff1a;android 最近痴迷上了android &#xff0c; 因为有java 语言的基础学起来自己感觉很…

安卓六大布局介绍

安卓六大布局 布局的介绍安卓六大布局 布局的介绍 用户使用安卓看到的应用界面&#xff0c;是通过布局和组件构成的&#xff0c;组件根据布局的格式排列&#xff0c;形成用户所看到的界面。 安卓六大布局 线性布局方式&#xff08;LinearLayout&#xff09; 按照垂直或者水平…

安卓线性布局

安卓线性布局 &#xff08;一&#xff09;界面与布局1、界面2、布局&#xff08;1&#xff09;UI容器&#xff08;2&#xff09;UI控件 (Control)&#xff08;3&#xff09;两种方式声明布局 &#xff08;二&#xff09;线性布局&#xff08;1&#xff09;常用属性 &#xff08…

安卓的常用布局看一篇就够了

目录 1-1 布局通用的属性 1-2 线性布局&#xff08;LinearLayout&#xff09; 1、常见属性&#xff1a; 2、线性布局的例子&#xff1a; 1-3 相对布局&#xff08;RelativeLayout&#xff09; 1、常见属性&#xff1a; 2、 相对布局的例子&#xff1a; 1-4 帧布局&a…

android布局技巧:创建高效布局

Android UI工具包提供了一些布局管理器&#xff0c;它们使用起来相当容易&#xff0c;而且&#xff0c;大多数的时候&#xff0c;你只需要使用它们最基本的特征来实现UI。 执着于基本特征的使用对于创建UI来说&#xff0c;往往不是最高效的。一个常见的例子就是滥用LinearLayo…

安卓7大基本布局

一&#xff1a;基础知识 1.Android七大基本布局分别是&#xff1a; LinearLayout(线性布局)、TableLayout(表格布局)、RelativeLayout(相对布局)、FrameLayout(层布局)、AbsoluteLayout(绝对布局)、GridLayout(网格布局)、ConstraintLayout(约束布局)。 2.七大基本布局的继承…

Android的六大基本布局

线性布局 LinearLayout相对布局 RelativeLayout表格布局 TableLayout绝对布局 AbsoluteLayout网格布局 GridLayout帧布局 FrameLayout 布局通用属性 属性名称功能描述android:id设置布局的标识android:layout_width设置布局的宽度android:layout_height设置布局的高度android:…

安卓布局详解:探索各种布局方式

文章目录 前言一、线性布局&#xff08;LinearLayout&#xff09;二、相对布局&#xff08;RelativeLayout&#xff09;三、帧布局&#xff08;FrameLayout&#xff09;四、表格布局&#xff08;TableLayout&#xff09;五、约束布局&#xff08;ConstraintLayout&#xff09;六…

微信小程序页面布局——上中下结构

小程序页面布局——上中下结构 内容简述 上中下结构&#xff1a;头脚固定中间滚动框 使用UI框架&#xff1a;Vant Weapp(引入安装参考) 为了方便&#xff0c;使用了less生成wxss&#xff0c;所以展示的是less代码&#xff0c;有需要可以看&#xff1a;https://www.jianshu.com…

微信小程序中的常用布局方式(总结)

参照Android开发&#xff0c;总结了微信小程序的常用的两种布局方式&#xff1a;1、线性布局&#xff08;横版、竖版&#xff09;。2、网格布局。 效果图如下&#xff1a; 一、网格布局 &#xff08;1&#xff09;固定Item个数的网格布局&#xff0c;主要用于功能模块入口展示…

微信小程序页面布局

一,微信小程序页面布局方式采用的是Flex布局 1.Flex布局&#xff0c;是W3c在2009年提出的一种新的方案&#xff0c;可以简便&#xff0c;完整&#xff0c;响应式的实现各种页面布局。 2.Flex布局提供了元素在容器中的对齐&#xff0c;方向以及顺序&#xff0c;甚至他们可以是动…

html的网格布局

网格布局 学习总结&#xff1a; 从7.19进入csdn夏令营后&#xff0c;感谢各位老师的辛苦讲解与发布任务&#xff0c;我对C1能力认证中web方面的知识有了极大的领会。学习过程中既温习了在校学习的知识&#xff0c;也学到了诸如网格布局&#xff0c;动画&#xff0c;less&#x…

网格布局(grid布局)

网格布局 他可以将页面分为多个网格&#xff0c;可以任意组合不同的网格 &#xff0c;做出各种各样的布局。 网格布局为二维性质的。 设置行、列间距 grid-row-gap:1rem ;行间距 ** grid-column-gap: 1rem ;列间距** ** grid-gap: 1rem;**设置行列间距 设置容器的列宽和与…

CSS布局—网格布局Grid(一)

CSS网格可以定义由行和列组成的二维布局&#xff0c;然后将元素放置到网格中。有些元素可能只占据网格的一个单元&#xff0c;另一些元素则可能占据多行或多列。网格的大小既可以精确定义&#xff0c;也可以根据自身内容自动计算。你既可以将元素精确地放置到网格某个位置&…

CSS Grid 网格布局教程

一、概述 网格布局&#xff08;Grid&#xff09;是最强大的 CSS 布局方案。 它将网页划分成一个个网格&#xff0c;可以任意组合不同的网格&#xff0c;做出各种各样的布局。以前&#xff0c;只能通过复杂的 CSS 框架达到的效果&#xff0c;现在浏览器内置了。 上图这样的布局&…

css 网格布局

简介&#xff1a; 网格是由一系列水平及垂直的线构成的一种布局模式。一个网格通常具有许多的列&#xff08;column&#xff09;与行&#xff08;row&#xff09;&#xff0c;以及行与行、列与列之间的间隙&#xff0c;这个间隙一般被称为沟槽&#xff08;gutter&#xff09;。…