学习使用ConstraintLayout布局实战

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dingshuhong_/article/details/80195498

一、概述

ConstraintLayout 布局已经出来有一两年了,最先开始因为视图化的布局,所以一直没有使用过,最近浏览其他博客的时候,多次看到ConstraintLayout 是官方推荐使用的布局,而且相对于其他的四大布局,有很多性能方面的优势。所以有必要学习和使用一下这个布局。下面开始吧!
引入依赖(已经到1.1版本了,是应该多尝试使用这个布局了)

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

二、效果展示

不喜欢视图化布局,其实也可以手写属性来布局。下面展示下我看hongyang大神博客时手写布局的效果。
布局效果
下面是布局xml代码:

<?xml version="1.0" encoding="utf-8"?>
<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">

    <ImageView  android:id="@+id/img_banner" android:layout_width="0dp" android:layout_height="0dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="15dp" android:background="@color/colorPrimaryDark" app:layout_constraintDimensionRatio="H,16:9" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" />

    <ImageView  android:id="@+id/img_left" android:layout_width="146dp" android:layout_height="86dp" android:layout_marginBottom="10dp" android:layout_marginLeft="12dp" android:layout_marginTop="10dp" android:background="@color/colorPrimary" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toBottomOf="@+id/img_banner" />

    <TextView  android:id="@+id/txt_content" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:text="马云:一年交税170多亿马云:一年交税170多亿马云:一年交税170多亿" app:layout_constraintLeft_toRightOf="@+id/img_left" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="@+id/img_left" />

    <TextView  android:layout_width="0dp" android:layout_height="wrap_content" android:text="8分钟前" app:layout_constraintBottom_toBottomOf="@+id/img_left" app:layout_constraintLeft_toLeftOf="@+id/txt_content" />

    <TextView  android:layout_width="60dp" android:layout_height="60dp" android:background="@color/colorPrimary" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintHorizontal_bias="0.9" app:layout_constraintVertical_bias="0.9"/>
    <TextView  android:id="@+id/tab1" android:layout_width="0dp" android:layout_height="40dp" android:background="@android:color/darker_gray" android:gravity="center" android:text="tab1" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintHorizontal_chainStyle="spread" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toLeftOf="@+id/tab2" />

    <TextView  android:id="@+id/tab2" android:layout_width="0dp" android:layout_height="40dp" android:background="@android:color/holo_green_light" android:gravity="center" android:text="tab1" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintHorizontal_chainStyle="spread" app:layout_constraintLeft_toRightOf="@+id/tab1" app:layout_constraintRight_toLeftOf="@+id/tab3" />

    <TextView  android:id="@+id/tab3" android:layout_width="0dp" android:layout_height="40dp" android:background="@android:color/holo_red_light" android:gravity="center" android:text="tab1" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintHorizontal_chainStyle="spread" app:layout_constraintLeft_toRightOf="@+id/tab2" app:layout_constraintRight_toRightOf="parent" />

</android.support.constraint.ConstraintLayout>

三、属性介绍

结合这个上面这个布局介绍下ConstraintLayout的属性吧

1、相对位置(Relative positioning)

在横向和纵向上添加约束关系来固定控件位置,官方一共提供给我们这些相对约束属性:这里写图片描述
下面我们对比下效果
没有添加约束

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent">

    <Button  android:id="@+id/btn_01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮01"/>

    <Button  android:id="@+id/btn_02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮2"/>

</android.support.constraint.ConstraintLayout>

没有添加按钮2在按钮1的右边的约束

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout  xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent">

    <Button  android:id="@+id/btn_01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮01"/>

    <Button  android:id="@+id/btn_02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮2" app:layout_constraintLeft_toRightOf="@+id/btn_01"/>

</android.support.constraint.ConstraintLayout>

没有添加约束没有添加按钮2在按钮1的右边的约束
仅仅添加了一个app:layout_constraintLeft_toRightOf="@+id/btn_01"属性就可以达到了RelativeLayout布局的android:layout_toLeftOf="@id/btn_1"所要的效果。
相对位置的约束属性的格式基本是layout_constraintxxx_toxxxOf=id这种格式,理解起来其实并不难,constraintxxx代表当前控件的约束方向,如上图的效果constraintLeft就是就是btn_02按钮的左边约束。toxxxOf被约束的控件的方向,如上图id是btn_01 就代表与id为btn_01控件的右边方向约束在一起。app:layout_constraintLeft_toRightOf="@+id/btn_01"结合起来就是当前控件btn_01按钮的左边与id为btn_01的控件的右边相约束。 关于约束这个词的理解,你可以理解成用带弹性的绳子相连接起来。
下面在展示几个例子:
按钮01 在按钮02的正下方

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout  xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent">

    <Button  android:id="@+id/btn_01" android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent" android:text="按钮01"/>

    <Button  android:id="@+id/btn_02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮2" app:layout_constraintLeft_toLeftOf="@+id/btn_01" app:layout_constraintTop_toBottomOf="@+id/btn_01" app:layout_constraintRight_toRightOf="@+id/btn_01"/>


</android.support.constraint.ConstraintLayout>

首先对按钮01 使用app:layout_constraintLeft_toLeftOf="parent"和app:layout_constraintTop_toTopOf="parent" 使得按钮01的左边和顶部与父布局的左边和顶部约束,这样按钮就被固定在左上角。 然后对按钮02 使用app:layout_constraintLeft_toLeftOf="@+id/btn_01"将按钮02的左边与按钮01的左边相约束,然后使用app:layout_constraintTop_toBottomOf="@+id/btn_01" 让按钮02的顶部与按钮01的底部相约束,这样按钮02就在按钮01的正下方。最后使用 app:layout_constraintRight_toRightOf="@+id/btn_01" 让按钮02的右边与按钮01的右边相约束,保持永远对齐。

2、倾向(bias)

这里写图片描述
倾向分为两个方向 横向和纵向, 也就是说左右和上下两边出现受力不均,造成倾向,比如左边约束的力是右边约束的力之比是9:1

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout  xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent">

    <Button  android:id="@+id/btn_01" android:layout_width="180dp" android:layout_height="wrap_content" android:layout_marginLeft="80dp" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent" android:text="按钮01"/>

    <Button  android:id="@+id/btn_02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮2" app:layout_constraintTop_toTopOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintVertical_bias="0.3" app:layout_constraintHorizontal_bias="0.9"/>


</android.support.constraint.ConstraintLayout>

这里写图片描述
理解:左边的间距占左右边间距之和的90%,上间距占上下间距之和的30%

3、圆心定位

这是在1.1版本添加的新属性,貌似没有自动提示
这里写图片描述

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout  xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent">

    <Button  android:id="@+id/btn_01" android:layout_width="80dp" android:layout_height="wrap_content" android:layout_marginLeft="80dp" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintBottom_toBottomOf="parent" android:text="按钮01"/>

    <Button  android:id="@+id/btn_02" android:layout_width="80dp" android:layout_height="wrap_content" android:text="按钮2" app:layout_constraintCircle="@+id/btn_01" app:layout_constraintCircleRadius="90dp" app:layout_constraintCircleAngle="20"/>


</android.support.constraint.ConstraintLayout>

这里写图片描述
圆心定位意思就是基于两个控件的中心,通过radius和angle来控制控件的位置。angle角度不支持负值。默认以被定位控件(btn_01)的Y轴正方向为零度。

4、可见性约束

隐藏前隐藏后
可以看到区别开始是按钮01左边约束父布局的左边,然后按钮02约束按钮01的右边。 但是当按钮01隐藏以后,按钮02直接约束到父布局的左边,事实上按钮根本没有约束父布局的左边。 这里小编的理解,就是之前的隐藏的控件的布局约束依然有效,只不过按钮01的所有边距变成了0.如果你有更好的理解请告诉我,谢谢。

5、控件尺寸约束

通常我们定义控件的长和宽,android:layout_width=""和android:layout_height="" 来设置控件的大小。
ConstraintLayout布局设置方式:

  • 固定值
  • wrap_content
  • 0dp(相当于MATCH_CONSTRAINT)

那match_parent呢?看下面这段话

Important: MATCH_PARENT is not recommended for widgets contained in a ConstraintLayout. Similar behavior can be defined by using MATCH_CONSTRAINT with the corresponding left/right or top/bottom constraints being set to “parent”.

大概意思是不推荐使用match_parent在ConstraintLayout布局中设置大小,类似的功能可以使用约束设置左右或者上下指定约束到父布局上。
那怎样实现其他四大布局match_parent沾满父窗体剩下控件的效果呢? 可以使用0dp来代替
match_parent的效果

<?xml version="1.0" encoding="utf-8"?>
<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">

    <Button  android:id="@+id/btn_01" android:layout_width="80dp" android:layout_height="wrap_content" android:layout_marginLeft="48dp" android:layout_marginTop="112dp" android:text="按钮01" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent"/>

    <Button  android:id="@+id/btn_02" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮2" app:layout_constraintLeft_toRightOf="@+id/btn_01" app:layout_constraintRight_toRightOf="parent"/>
</android.support.constraint.ConstraintLayout>

这里写图片描述
0dp实现的效果

<?xml version="1.0" encoding="utf-8"?>
<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">

    <Button  android:id="@+id/btn_01" android:layout_width="80dp" android:layout_height="wrap_content" android:layout_marginLeft="48dp" android:layout_marginTop="112dp" android:text="按钮01" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent"/>

    <Button  android:id="@+id/btn_02" android:layout_width="0dp" android:layout_height="wrap_content" android:text="按钮2" app:layout_constraintLeft_toRightOf="@+id/btn_01" app:layout_constraintRight_toRightOf="parent"/>
</android.support.constraint.ConstraintLayout>

这里写图片描述

6、比例(Ratio)

app:layout_constraintDimensionRatio="H,16:9"
app:layout_constraintDimensionRatio="W,16:9"

这里的比例指的是占父布局的高度和宽度的比例

7、链条(Chains)

链条适合于横向或者纵向一排的控件的布局方式。
首先要创建一个链条,就是一排控件首位相互约束,如下图
这里写图片描述
这里写图片描述
类似的效果的代码像这样,创建了一个链条

<?xml version="1.0" encoding="utf-8"?>
<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">
    <TextView  android:id="@+id/tab1" android:layout_width="0dp" android:layout_height="40dp" android:background="@android:color/darker_gray" android:gravity="center" android:text="tab1" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toLeftOf="@+id/tab2" />

    <TextView  android:id="@+id/tab2" android:layout_width="0dp" android:layout_height="40dp" android:background="@android:color/holo_green_light" android:gravity="center" android:text="tab1" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toRightOf="@+id/tab1" app:layout_constraintRight_toLeftOf="@+id/tab3" />

    <TextView  android:id="@+id/tab3" android:layout_width="0dp" android:layout_height="40dp" android:background="@android:color/holo_red_light" android:gravity="center" android:text="tab1" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toRightOf="@+id/tab2" app:layout_constraintRight_toRightOf="parent" />

</android.support.constraint.ConstraintLayout>

效果就像这样
这里写图片描述
看似效果跟LinearLayout的比重布局很相似,但是它有和LinearLayout不一样的效果,就是给链条添加样式。
这里写图片描述

  • CHAIN_SPREAD 元素被分散开(默认样式)
  • 在CHAIN_SPREAD模式下,如果一些控件被设置为MATCH_CONSTRAINT,那么控件将会把所有剩余的空间均分后“吃掉”
  • CHAIN_SPREAD_INSIDE Chain两边的元素贴着父容器,其他元素在剩余的空间中采用CHAIN_SPREAD模式
  • CHAIN_PACKED Chain中的所有控件合并在一起后在剩余的空间中居中

四、总结

看完了关于ConstraintLayout布局属性的介绍,是不是感觉非常强大,不仅有丰富的相对位置约束,还有比例、倾向的设置,具备RelativeLayout和LinearLayout两个最常用布局的各种优点。关键在性能上也有优势,我们还有什么理由不尝试呢?
参考链接:
https://developer.android.google.cn/reference/android/support/constraint/ConstraintLayout
https://blog.csdn.net/lmj623565791/article/details/78011599

转载于:https://my.oschina.net/u/4112587/blog/3036618

ConstraintLayout——约束性布局学习 ConstraintLayout简介 Constraint Layout是Google在2016年的Google I/O大会上提出的一个可以灵活控制子控件的位置和大小的新布局。并且其号称可以实现布局最大程度的扁平化。 ConstraintLayout优点 我们知道项目中的布局嵌套问题对我们的项目性能有着不小的威胁。布局能实现扁平化的话会让软件性能得到很大的提升。所以我们在开发过程中都会尽... 阅读详情

相关推荐

Android ConstraintLayout 约束布局的使用手册

目前Android的默认布局早已改成ConstraintLayout,但是很多小伙伴还是使用过去的相对布局,觉得老的布局用起来熟悉,新布局使用复杂,从而失去了探索新大陆的机会,今天就让我们一起揭开ConstraintLayout的面纱,掌握Android新布局的使用方法。传统的布局容易在版本迭代过程中,造成页面层级过多的问题(俄罗斯套娃),一是对页面渲染有影响,二是不利于开发者的后期维护。

yzwfeng的专栏 3107

ConstraintLayout常用属性

ConstraintLayout就是常说的约束性布局,所谓约束性就是通过一些特定“条件”来控制View的位置。既然是约束View,那么就必须有一个“相对点”,就是不变的,这样我们才能进行约束,个人认为CostraintLayout的这个“相对点”就是父布局(ConstraintLayout)。 就像我们在一个空房子里面一样,怎么确定你站在那个位置?我们可以说在左上角、右下角、横向中间偏下多少米等这...

qq_24293111的博客 1245

Android Jetpack 实战:优化移动开发的布局性能

你是否遇到过这样的场景:用户反馈“打开商品详情页要卡3秒”、“滑动列表时像被胶水粘住”?这些体验问题的背后,往往藏着布局性能的“隐形杀手”——层级过深的XML布局、重复的measure/layout操作、冗余的绘制指令。本文聚焦Android布局性能优化。

移动开发前沿的博客 842

ConstraintLayout约束布局详解

前言:  ConstraintLayout 约束布局,由 2016 年 Google I/O 推出。为了解决布局嵌套和模仿前端flexible布局的一个新布局。减少布局的层级,优化渲染性能。它集 LinearLayout(线性布局),RelativeLayout(相对布局),百分比布局等的功能于一身,功能强大,使用灵活。 Google官方推荐所有操作都在”Design”区域搞定,即通过可视化拖...

远行的博客 1391

【MATLAB/Simulink】从模型到飞行:基于PX4与Rflysim的无人机MBD实战指南

本文详细介绍了基于MATLAB/Simulink与PX4、Rflysim的无人机模型开发与飞行控制实战指南。通过MBD(基于模型设计)方法,从建模、仿真到代码生成与硬件部署,实现无人机开发的高效闭环。文章涵盖开发环境搭建、动力学建模、控制算法实现及测试验证全流程,为无人机开发者提供实用技巧与优化建议。

weixin_30181209的博客 415

ArcGIS新手必看:HWSD2土壤数据从下载到批量提取TIFF的完整流程

本文详细介绍了ArcGIS中HWSD2土壤数据的完整处理流程,从数据下载、预处理到批量提取TIFF文件。涵盖栅格属性表构建、属性数据连接及性能优化等关键步骤,帮助新手高效掌握HWSD2数据提取技术,提升地理信息数据处理效率。

ll5678的博客 1038

ConstraintLayout 特殊用法详解

约束性控件ConstraintLayout的特殊用法

1553

LabVIEW+数据库应用系列保姆级教程,第一篇数据库连接

目录LabVIEW连接数据库的方法连接MySQL连接Oracle,SQL Server,Access等 LabVIEW连接数据库的方法 1、创建udl(Universal Data Link)是通用数据连接文件。界面操作,简单快捷。 2、编写连接字符串。需要熟悉连接字符串的结构,容易出错。 3、其他… 本教程教你使用第1种方法,也是最简单、最常用的方法。 连接MySQL 1、在MySQL Installer内安装MySQL Connector/ODBC,建议安装32位(X86),如下图: 2、创建ODBC

wwplh5520370的博客 1万+

约束布局ConstraintLayout总结

现在新技术层出不穷,如果每次出新的技术,我们都深入的研究的话,很容易分散精力。新的技术可能很久之后我们才会在工作中用得上,当学的新技术无法学以致用,很容易被我们遗忘,到最后真的需要使用的时候,又要从头来过(虽然上手会更快)。我觉得身为技术人,针对新技术应该是持拥抱态度的,入了这一行你就应该知道这是一个活到老学到老的行业,所以面对新技术,不要抵触,拥抱变化就好了。Flutter 明显是一种全新的技术,而对于这个新技术在发布之初,花一个月的时间学习它,成本确实过高。

2301_77595001的博客 1193

第八章 GPU Scheduler 分析:8.3 drm_sched_entity — 调度实体

本文介绍了DRM GPU调度器中的drm_sched_entity结构,它作为用户提交命令进入调度器的提交通道,解决了归属、排序和公平性问题。文章首先分析了命令提交的归属需求,然后详细阐述了entity的核心模型,包括其职责、进程映射关系和核心字段。接着说明了用户态提交进入内核后的关键节点路径,以及entity内部的FIFO语义和激活机制。entity通过组织同一context的命令提交包为FIFO队列,使调度器能够在多个entity之间进行优先级和公平性调度,同时保证同一提交通道的顺序执行。

图形/计算GPU的驱动与虚拟化技术分享园地 671

10年上位机开发踩过的20个坑:C#通信/线程/UI适配避坑指南

通信层:所有通信操作异步化、异常全覆盖,加断线重连+心跳检测,多设备隔离资源;线程层:UI更新必做跨线程判断,共享数据加锁,线程池限流,异常不静默;UI层:适配高分屏/DPI,用布局容器替代固定坐标,多屏场景绑定主屏幕。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 911

Android布局之ConstraintLayout

这篇材料本来是我给公司同事培训Android基础时弄的,对ConstraintLayout布局做了个简单介绍和使用,也放出来吧,有需要的还可以瞅两眼。 介绍 早在2017年的时候,Google就发布了 Android Studio 2.3 正式版,在这个版本中新建Module中默认的布局就是 ConstraintLayout 。 ​ConstraintLayout 也就是约束布局,和其他布局一样,...

程序员大佬超的博客 2040

OpenCV-Python实战(26)——复杂场景下的实时物体检测与跟踪

本节介绍了一种鲁棒的特征跟踪方法,该方法速度足够快,能够实时应用于网络摄像头的视频流。首先,算法展示了如何在一幅图像中提取和检测重要特征——无论是我们感兴趣的模板图像(训练图像),还是预期包含该物体的更复杂场景(查询图像),这些特征都具有视角和尺寸不变性。然后对关键点进行聚类,找到两幅图像中特征点之间的匹配。在此基础上,可以计算出一个将一组特征点映射到另一组的透视变换矩阵。利用这些信息,我们可以在查询图像中勾勒出训练图像的轮廓,并对查询图像进行透视变换,使感兴趣的物体以直立状态显示在屏幕中央。

盼小辉丶的博客 2073

动态图解&实例 ConstraintLayout Chain(1)

所以这一小节也顺便讲解。

egrhef的博客 785

【OpenClaw从入门到精通】第23篇:OpenClaw办公自动化实战—报表生成+文档批量处理+跨系统同步(2026实操进阶版)

本文聚焦OpenClaw在办公自动化场景的进阶应用,针对职场中高频且重复的报表生成、文档批量处理、跨系统数据同步三大痛点,提供从环境搭建、原理讲解到完整代码实现的全流程实操指南。方案基于Python生态工具链(pandas、Playwright、PyPDF2等)与OpenClaw的低代码编排能力,兼顾新手入门与进阶提升——新手可直接复用代码快速落地,进阶读者可学习流程编排逻辑进行二次开发。所有案例均基于真实办公场景设计,部分虚拟场景已明确标注,代码经本地环境验证可复现。

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 971

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

Android 获取 XML 布局位置

Android架构学习进阶是一条漫长而艰苦的道路,不能靠一时激情,更不是熬几天几夜就能学好的,必须养成平时努力学习的习惯。所以:贵在坚持!上面分享的字节跳动公司2021年的面试真题解析大全,笔者还把一线互联网企业主流面试技术要点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节。【Android高级架构视频学习资源】Android部分精讲视频领取学习后更加是如虎添翼!进军BATJ大厂等(备战)!

2401_84121603的博客 769

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Android修行手册-那试探布局的初次体验

【Android 详细知识点思维脑图(技能树)】我个人是做Android开发,已经有十来年了,目前在某创业公司任职CTO兼系统架构师。虽然 Android 没有前几年火热了,已经过去了会四大组件就能找到高薪职位的时代了。这只能说明 Android 中级以下的岗位饱和了,现在高级工程师还是比较缺少的,很多高级职位给的薪资真的特别高(钱多也不一定能找到合适的),所以努力让自己成为高级工程师才是最重要的。这里附上上述的面试题相关的几十套字节跳动,京东,小米,腾讯、头条、阿里、美团等公司19年的面试题。

2401_83817689的博客 867

IEM模型,地表粗糙度模拟

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

Android 五大布局实战指南:从LinearLayout到ConstraintLayout

本文详细解析Android五大核心布局:LinearLayout、RelativeLayout、FrameLayout、GridLayout和ConstraintLayout的实战应用与性能对比。重点介绍了ConstraintLayout的约束关系和扁平化层级优势,帮助开发者提升界面开发效率并优化性能,避免过度嵌套布局。

qq_27496129的博客 653

Android布局及代码优化_android 约束布局优点

最近遍览了各种网络安全类的文章,内容参差不齐,其中不伐有大佬倾力教学,也有各种不良机构浑水摸鱼,在收到几条私信,发现大家对一套完整的系统的网络安全从学习路线到学习资料,甚至是工具有着不小的需求。比如说程序的所有界面都有一个公共的部分,这个时候最好的做法就是将这个公共的部分提取到一个独立的布局文件当中,然后在每个界面的布局文件当中来引用这个公共的布局。优点:可以通过布局文件的可视化的视图,按照简单粗暴的"拖拉拽"的形式进行控件的摆放,和位置的约束,前文已经演示和介绍过,此处不再赘述。

2401_84545291的博客 674

Android约束布局ConstraintLayout的使用

Android约束布局ConstraintLayout的基本使用 约束布局ConstraintLayout面世已有很长一段时间了,但我一直没有关注这个Android 中继五大布局后的新布局的使用。近日在网友的讨论的强烈推荐下,尝试了ConstraintLayout。使用之后的最大感触就是:为什么我不早点在项目中尝试ConstraintLayout!!! 本篇文章,旨在记录ConstraintLay...

qq_36046305的博客 2万+

Android 的 ConstraintLayout 布局使用

加依赖:确保里有。定根布局:根标签用。放视图:把ButtonTextView等放进去。添约束(最关键!:为每个视图的水平方向和垂直方向至少各加一个约束。水平方向:约束Start或End。垂直方向:约束Top或Bottom。常用目标parent(父布局)或其他视图的id。打开 Android Studio 的布局编辑器,直接拖拽控件,观察它自动生成的约束代码,这是最快的学习途径!场景推荐选择理由新项目开发性能好、功能强、现代标准复杂界面减少嵌套、响应式支持好简单相对定位代码更简洁直观。

m0_61945436的博客 1314

基础布局之ConstraintLayout约束布局

基础布局之ConstraintLayout约束布局

似霰的博客 7094

ConstraintLayout(约束布局)使用详解

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

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

ConstraintLayout 布局详解

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

st526403649的博客 7812
上一篇: 微信小程序--rpx单位的理解
下一篇: 深入理解gradle项目构建---Task学习
chuozhenwang2889
博客等级 码龄11年 0粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址