ConstraintLayout的基本用法及优点

Android ConstraintLayout用法全解析 ConstraintLayout 用法全解析 文章目录ConstraintLayout 用法全解析前言一、 什么是ConstraintLayout?二、 ConstraintLayout的优缺点?2.1 优点2.1 缺点三、 基本使用方法3.1 最基础使用 --- 位置约束3.2 文字基线对齐3.3 居中和bias百分比偏移3.4 角度约束3.5 margin 和 goneMargin3.6 0dp(MATCH_CONSTRAINT)与组件大小3.7 0dp与宽高比例3. 8 Chains(约束链)3.9 阅读详情

为什么推荐使用ConstraintLayout

ConstraintLayout(约束布局)在2016年的Google I/O大会上就推出来了,经历这两年的迭代,功能已经非常的成熟了。一次偶然的机会,在项目中尝试了使用约束布局,从此被它的功能所深深折服。它能很轻易的将你从使用层层的嵌套去实现复杂的布局中解放出来。使用ConstraintLayout后基本可以抛弃LinearLayout和RelativeLayout的使用。完全不需要任何嵌套就可以实现复杂的UI,使用起来特别清爽。所以相信我,使用过就会爱上它。

约束布局的终极奥义!

① 如何才能使用?

因为ConstraintLayout的是在Support包中提供的,所以只需要在我们主Module的build.gradle中添加如下依赖:

implementation 'com.android.support.constraint:constraint-layout:1.1.3'

然后,我们就可以直接在我们的xml文件中直接应用了:

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="@color/white"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <!--具体布局-->
</android.support.constraint.ConstraintLayout>
② 可以用来干什么?
  • layout_constraintDimensionRatio(控制布局比例):
    我们经常会遇到某些布局需要展示特殊的比例(16:9、2:1、4:3等等)。在以前我们可能会自定义一个ViewGroup,动态的去计算比例,比较麻烦。而使用ConstraintLayout后,我们可以直接使用这个属性,以设置某个View的长宽比例为16:9为例:
<ImageView
    android:layout_width="match_parent"
    android:layout_height="@dimen/dimen_0dp"
    app:layout_constraintDimensionRatio="16:9"/>

在这里插入图片描述

  • layout_constraintRight_toRightOf(与RelativeLayout相似的属性toRightOf等一整套的属性):
    如果你想使用RelativeLayout中的toLeftOf或者toRightOf等属性,约束布局同样提供了一套类似的属性。比如:按钮A在屏幕的左上方;按钮B在按钮A的右方;按钮C在按钮B的下方并且水平居中;按钮D在按钮C的下方并且处于屏幕的右侧。
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="@color/white"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <Button
        android:id="@+id/this_is_a"
        android:layout_width="150dp"
        android:layout_height="50dp"
        android:textSize="@dimen/dimen_20sp"
        android:textColor="@color/black"
        android:text="A"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>
    <Button
        android:id="@+id/this_is_b"
        android:layout_width="150dp"
        android:layout_height="50dp"
        android:textSize="@dimen/dimen_20sp"
        android:textColor="@color/black"
        android:text="B"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toRightOf="@+id/this_is_a"/>

    <Button
        android:id="@+id/this_is_c"
        android:layout_width="150dp"
        android:layout_height="50dp"
        android:textSize="@dimen/dimen_20sp"
        android:textColor="@color/black"
        android:text="C"
        android:layout_marginTop="@dimen/dimen_10dp"
        app:layout_constraintTop_toBottomOf="@+id/this_is_b"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"/>

    <Button
        android:id="@+id/this_is_d"
        android:layout_width="150dp"
        android:layout_height="50dp"
        android:textSize="@dimen/dimen_20sp"
        android:textColor="@color/black"
        android:text="D"
        android:layout_marginTop="@dimen/dimen_10dp"
        app:layout_constraintTop_toBottomOf="@+id/this_is_c"
        app:layout_constraintRight_toRightOf="parent"/>
</android.support.constraint.ConstraintLayout>

相对布局类似属性示例图

  • layout_constraintHorizontal_chainStyle
    对于按钮A和按钮B在横向上,我们通过更改其chainStyle属性(packed、spread、spread_inside)。
    <Button
        android:id="@+id/this_is_a"
        android:layout_width="150dp"
        android:layout_height="50dp"
        android:textSize="@dimen/dimen_20sp"
        android:textColor="@color/black"
        android:text="A"
        app:layout_constraintHorizontal_chainStyle="packed"
        app:layout_constraintRight_toLeftOf="@+id/this_is_b"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>
    <Button
        android:id="@+id/this_is_b"
        android:layout_width="150dp"
        android:layout_height="50dp"
        android:textSize="@dimen/dimen_20sp"
        android:textColor="@color/black"
        android:text="B"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintLeft_toRightOf="@+id/this_is_a"/>

在这里插入图片描述

  • Barrier

我们经常会有这样的需求,我们某一个控件必须在某一组控件的某一侧。如下图所示button和textView无论位置或者长度怎么变化,checbox始终在他们的右侧。
在这里插入图片描述

xml中我们需要使用android.support.constraint.Barrier:

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="@color/white"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <Button
        android:id="@+id/this_is_a"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:textSize="@dimen/dimen_20sp"
        android:textColor="@color/black"
        android:text="AAAAAAAAAAAAAAAAAA"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>
    <TextView
        android:id="@+id/this_is_b"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:textSize="@dimen/dimen_20sp"
        android:textColor="@color/black"
        android:text="BBBB"
        app:layout_constraintTop_toBottomOf="@+id/this_is_a"/>

    <android.support.constraint.Barrier
        android:id="@+id/this_is_barrier"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:barrierDirection="end"
        app:constraint_referenced_ids="this_is_a,this_is_b"
        />

    <CheckBox
        android:id="@+id/this_is_c"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="@dimen/dimen_20sp"
        android:textColor="@color/black"
        android:text="CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
        android:layout_marginTop="@dimen/dimen_10dp"
        app:layout_constraintLeft_toRightOf="@+id/this_is_barrier"/>
</android.support.constraint.ConstraintLayout>
  • Group
    在以前,如果我们需要控制某一组控件的隐藏或者显示,通常会使用一个ViewGroup包裹一下,但是现在有了Group,完全不需要了,还是上面同样的例子,我们加一个Group:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="@color/white"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <Button
        android:id="@+id/this_is_a"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:textSize="@dimen/dimen_20sp"
        android:textColor="@color/black"
        android:text="AAAAAAAAAAAAAAAAAA"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>
    <TextView
        android:id="@+id/this_is_b"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:textSize="@dimen/dimen_20sp"
        android:textColor="@color/black"
        android:text="BBBB"
        app:layout_constraintTop_toBottomOf="@+id/this_is_a"/>
        
    <android.support.constraint.Group
        android:id="@+id/this_is_group"
        android:visibility="invisible"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:constraint_referenced_ids="this_is_a,this_is_b"/>

    <android.support.constraint.Barrier
        android:id="@+id/this_is_barrier"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:barrierDirection="end"
        app:constraint_referenced_ids="this_is_a,this_is_b"
        />

    <CheckBox
        android:id="@+id/this_is_c"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="@dimen/dimen_20sp"
        android:textColor="@color/black"
        android:text="CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
        android:layout_marginTop="@dimen/dimen_10dp"
        app:layout_constraintLeft_toRightOf="@+id/this_is_barrier"/>
</android.support.constraint.ConstraintLayout>

通过控制Group的可见性即可控制referenced_ids中申明的控件组的可见性了。注意一点,不要把一个控件申明在不同的Group中,这样有可能会导致设置可见性失效哦。

  • Guideline

利用这个控件,可以辅助我们布局UI。在实际运行以后,这条线我们是看不到的:
在这里插入图片描述

布局我们可以这么写:

<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.constraint.Guideline
        android:id="@+id/guideline"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_begin="16dp" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        app:layout_constraintStart_toStartOf="@+id/guideline"
        app:layout_constraintTop_toTopOf="parent"
        tools:text="TextView" />

</android.support.constraint.ConstraintLayout>

有什么优点

上面介绍了ConstraintLayout的部分功能,强烈推荐你去使用感受一下,在你使用过程中才能真正的体会到爽快。那我们使用约束布局会有什么优点呢?
我们使用ConstraintLayout之后,减少了很多的嵌套的层级。这样View在渲染的时候,减少了很多多余的measure和layout的开销。据统计,使用约束布局替代以前的嵌套结构可以提升40%的速度。如果你嵌套的层次越多,提升的效果越明显。所以,建议我们现在的开发者强制推行使用ConstraintLayout,无论从开发速度还是页面的渲染速度都是提升明显的。

更多Android、Java进阶知识微信搜索公众号:南京Android部落

ConstraintLayout-那些很有用但是你可能不知道的用法 ConstraintLayout-那些很有用但是你可能不知道的用法 前沿 本篇不讲ConstraintLayout的常规用法,会讲一些约束布局很用的,但是可能你并不知道的用法 一、B相对于A底部居中对齐 如上图所示:需要B布局相对于A布局的底部垂直居中对齐,水平居中对齐 方案1 使用LinearLayout为外层布局 需要指定B一个固定高度 给定B一个负的向上的margin,值为B高度的一半 代码和效果如下所示: 缺陷:很明显,如果只是使用XML布局的形式(不通过代码动态计算),B布局需要固定一个高 阅读详情

相关推荐

Android ConstraintLayout的常见用法

ConstraintLayout 是 Android 中功能强大的扁平化布局容器,主要通过设置控件之间的来定位和确定大小。

yeziyfx的专栏 1122

约束布局ConstraintLayout看这一篇就够了

目录 1.介绍 2.为什么要用ConstraintLayout 3.如何使用ConstraintLayout 3.1 添加依赖 3.2 相对定位 3.3 角度定位 3.4 边距 3.5 居中和偏移 3.6 尺寸约束 3.7 链 4.辅助工具 4.1 Optimizer 4.2 Barrier 4.3 Group 4.4 Placeholder 4.5.Guideline 5.总结 1.介绍 约...

weixin_34167819的博客 3667

Android界面布局深入解析与实战应用

在AbsoluteLayout中,子视图的位置是通过layout_x和layout_y属性来指定的,这些属性决定了子视图在布局中的具体位置。通过设置这些属性,开发者能够精确控制每个控件在屏幕上的显示位置。下面是一个简单的AbsoluteLayout的使用示例:<Button<TextView在上述代码中,Button和TextView通过指定layout_x和layout_y属性被放置在AbsoluteLayout的绝对位置上。

weixin_32480007的博客 825

ConstraintLayout(约束布局)使用详解

ConstraintLayout 是一个使用“相对定位”灵活地确定微件的位置和大小的一个布局,在 2016 年 Google I/O 中面世,它的出现是为了解决开发中过于复杂的页面层级嵌套过多的问题——层级过深会增加绘制界面需要的时间,影响用户体验,以灵活的方式定位和调整小部件。从 Android Studio 2.3起,创建layout文件就已经是默认ConstraintLayout了,但是尽管Google如此大力推这项技术,但在当时很少有人使用,近些年逐渐被大家拿起来,啊真香!(此处无图胜有图)。

一个IT人的技术成长历程。 9475

COMSOL中的动网格

首先我们先了解几个概念 (1)网格重划分(remesh):就是在某些特定的区域进行网格的重新划分,在Maxwell软件中的直线运动区域,当运动物体运动后,这个区域进行重新划分。 (2)morph:网格不重新划分,小范围的进行网格变形,针对运动物体运动位移较小,对变形区域不进行重划分,能够提高效率。 (3)网格滑移(sliding):针对圆形运动区域,运动与非运动区域进行网格滑移,当然边界上两侧网格不共节点,该方法不需要网格重新划分,大部分软件针对圆形运动区域采用该方法,比如maxwell的band,b

midiio的博客 7870

别再手动改文献了!手把手教你定制Mendeley的GB/T 7714-2005引用格式(附常见问题修复)

本文详细指导如何定制Mendeley的GB/T 7714-2005引用格式,解决科研文献管理中的常见问题。通过深度解析Mendeley样式编辑器,精准控制作者显示规则、出版社信息精简及期刊页码处理,实现参考文献一键合规。附常见问题修复和实战调试方法,大幅提升学术写作效率。

weixin_26833503的博客 374

最全面的ConstraintLayout教程

亲自执笔,给大家带来新年第一篇原创文章

郭霖 5845

gnuradio+b210实现FM收音机

gnuradio+b210实现FM收音机环境介绍FM接收1 Flow Graph2 变量参数FM发射1 Flow Graph 环境介绍 Name Version gnuradio 3.7.14.0 uhd 3.15.0.0 ubuntu 18.04 usrp b210 参考 https://www.ijedr.org/papers/IJEDR1702038.pdf Audio File Transmission using GNURADIO and USRP FM接

u011745228的博客 5127

【Android】ConstraintLayout约束布局最全解析

ConstraintLayout约束布局最全解析一、ConstraintLayout概述二、ConstraintLayout基础篇2.1 基础操作2.2 控件间添加约束2.3 约束布局xml代码实现三、ConstraintLayout 进阶篇3.1 Chains链3.2 尺寸约束3.3 百分比布局3.4 radio属性3.5 圆形定位四、ConstraintLayout 高级篇4.1 Guideline4.3 Group4.2 Barrier 一、ConstraintLayout概述 Constraint

lucashu的博客 3万+

AXI Timer IP核使用说明

AXI Timer是提供定时技术功能的集成IP核,具有时间生成、事件捕获、产生PWM波以及产生中断的功能,下面具体讲述Timer IP核的使用说明。

weixin_43418104的博客 2489

施耐德 Modicon M580 ePAC 项目实战:从硬件选型到 Control Expert V15 组态

本文详细解析了施耐德 Modicon M580 ePAC 在工业自动化项目中的实战应用,从硬件选型到 Control Expert V15 组态的全流程。重点介绍了水处理站控制系统的硬件配置、网络架构设计、软件安装授权及程序框架开发,帮助工程师高效实施中大型控制系统项目。

weixin_33701617的博客 328

基础布局之ConstraintLayout约束布局

基础布局之ConstraintLayout约束布局

似霰的博客 7094

机器学习之多种算法优缺点总结及优化方法

一、无监督算法: 1、聚类算法:Kmeans 2、关联规则算法:Apriori 二、有监督算法 1、分类算法 决策树(Decision Tree) 支持向量机(SVM) K近邻(kNN,k-NearestNeighbor) 朴素贝叶斯 逻辑回归 2、回归算法 线性回归 多项式回归 3、集成算法 a、bagging(Bootstrapped Aggregation) 随机森林 ...

平原的博客 7081

约束布局Constraintlayout使用解析

1.简介 约束布局ConstraintLayout 是一个ViewGroup,可以在Api9以上的Android系统使用它,它的出现主要是为了解决布局嵌套过多的问题,以灵活的方式定位和调整小部件。从 Android Studio 2.3 起,官方的模板默认使用 ConstraintLayout。 ConstraintLayout 官方文档 2.为什么要用ConstraintLayout 在开发过程中经常能遇到一些复杂的UI,可能会出现布局嵌套过多的问题,嵌套得越多,设备绘制视图所需的时间和计算功耗也就越多。

ruanyandong的博客 1872

Nuxt - 项目打包部署及上线到服务器流程(SSR 服务端渲染)

Nuxt-项目打包部署及上线到服务器流程,详细介绍Nuxt项目上线部署,服务端渲染(ssr)项目及nuxt项目部署过程,nuxt项目打包上线,Nuxt项目的部署教程,NuxtJS项目部署方案,Nuxt如何部署到线上,nuxt项目部署篇,Nuxt项目搭建到Nuxt项目部署,Nuxt项目从开始到部署,详细教程。服务器部署nuxt项目,nuxt服务端部署上线,在服务器上部署nuxt项目,NuxtJS项目——命令和部署。......

🏆 前端领域优质创作者 1万+

Python爬虫实战:东方财富股吧与雪球舆情数据实时爬取与情绪指标挖掘

本文详细介绍如何使用Python爬虫技术实时爬取东方财富股吧和雪球平台的讨论数据,结合股价波动构建情绪分析指标。我们将使用最新的异步爬虫技术、自然语言处理方法和可视化工具,为量化交易提供数据支持。文章包含完整的代码实现和技术细节,适合有一定Python基础的读者学习。

2201_76125261的博客 1224

constraintlayout_Constraintlayout约束布局三问

Constraintlayout——约束布局,作为Jetpack的一个组件推出。今天的面试三问就是关于布局的:说说constraintlayout的主要特性,为什么会设计出这一种布局?说说你所了解的constraintlayout属性以及这些属性的用法说说constraintlayout的主要特性,为什么会设计出这一种布局?ConstraintLayout名字叫约束布局,跟Relativ...

weixin_39673293的博客 241

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

constraintlayout嵌套_ConstraintLayout用法详解

前几天,我刚写了一篇批判社会的文章。如今滴滴司机的事件让全国知道这件事儿的人聚拢了起来。其实生活在这种环境下,我们会不得不像生活妥协。用《我不是药神》的一句话就是:“我相信未来一定会更好”。说在前头以前在写布局的时候,经常会写出这样的布局:android:layout_width="match_parent"android:layout_height="match_parent"android:o...

weixin_39993322的博客 1321

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

android ConstraintLayout约束布局基本用法

1.一个控件可以有四个约束点:分别是左上右下,如下图: 如果是白点就是添加了约束点,如果是空心点,则是没有添加约束。 2.如果宽度或高度为0dp则是约束布局的特性,它属于在约束条件下的match_parent 如上图所示的button就是高度0dp,但是在hello world的约束下。 3.Guideline 参考线 第一步点击上图所示添加参考线,第二步将参考线修改成百分比...

龚礼鹏的博客 1871

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

护眼显示器怎么选?从蓝光、频闪到亮度均匀性的科学指南

长时间面对屏幕,眼睛干涩、疲劳甚至视力下降,已成为现代人普遍的健康困扰。要真正实现护眼,不能只靠贴上防蓝光膜或调低亮度,而需要从显示器的核心光学原理入手:蓝光波段能量分布、背光调光方式(DC调光与PWM调光的区别)、亮度均匀性、色温准确度以及环境光与屏幕亮度的匹配关系。理解这些技术概念,才能科学评估一款显示器是否真正护眼。低蓝光模式并非简单地降低亮度或偏黄,而是通过硬件或软件精确过滤有害蓝光波段;屏幕频闪则可能引发头痛和视觉疲劳,DC调光能有效减少这种隐性伤害。此外,亮度均匀性和防眩光涂层直接影响长时间观看

weixin_33770878的博客 418

Android中ConstraintLayout布局的基本用法

约束布局(ConstraintLayout)是目前谷歌推荐的一种布局,它的功能强大。相对于LinearLayout和RelationLayout相比,它的用法更加灵活,同时代码量更小。下面介绍一下约束布局的简单用法。

weixin_40252011的博客 1170

ConstraintLayout 核心用法

文章目录ConstraintLayout 核心用法1. constraint2. pack3. align(各种对齐方式,可对多个控件使用)4. Guidelines(辅助线) ConstraintLayout 核心用法 AndroidStudio新建的工程默认布局就是ConstrainsLayout,之所以这样是因为Google推荐我们这么做。ConstrainsLayout是RelativeL...

百里屠苏的博客 616

ConstraintLayout 的用法

1、app:layout_constraintLeft_toLeftOf //Constrains the left side of a child to the left side of a target child (contains the target child id). 表示此控件的左边框与某个控件的左边框对齐或者在其右边 2、app:layout_constraintLeft_toRightOf //Constrains the left side of a child to the rig

qq_32664007的博客 385

constraintlayout嵌套_ConstraintLayout 用法

可以看到,第一个Group通过app:constraint_referenced_ids指定了a、c两个控件,这样当该Group可见性为invisible时,a、c的可见性都会变为invisible,为gone则都为gone。所以Group很适合处理有网无网之类的场景,不再需要像之前那样一个一个view控制可见性,通过Group就可以统一处理了。Group有一些注意事项:xml中,可见性配置的优先...

weixin_39829501的博客 526

ConstraintLayout 用法全解析

本文是基于constraint-layout:1.1.2 一、前言 在以前,android是使用布局如LinearLayout 、RelativeLayout等来构建页面,但这些布局使用起来很麻烦,并且经常需要一层一层嵌套,写一个简单的页面就需要费很大的劲。所以在16年I/O大会上,google发布了全新的布局-ConstraintLayout,其他布局和ConstraintLayout比起来,根本就没有存在的必要了... ConstraintLayout具有以下优势: 较高的性能优势。 布.

yzwfeng的专栏 3226

ConstraintLayout约束布局的基本用法

ConstraintLayout是一个ViewGroup,它与RelativeLayout(相对布局)相似,其中所有的视图根据试图与之间的关系进行布局,但灵活性要高于RelativeLayout。它的出现主要是为了解决布局嵌套过多的问题,可以灵活地调整定位和控件。

m0_74000465的博客 508
上一篇: 进阶必备-Android事件分发机制
下一篇: 进阶必备-Android Click事件是如何触发的?
IT烂笔头
博客等级 码龄15年 621粉丝 78原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值