Constraintlayout
androidx.constraintlayout.widget
最近更新时间 | 当前稳定版 | 下一候选版本 | Beta 版 | Alpha 版 |
---|---|---|---|---|
2020 年 12 月 17 日 | 2.0.4 | - | - | 2.1.0-alpha2 |
如需添加 ConstraintLayout 的依赖项,您必须将 Google Maven 代码库添加到项目中。如需了解详情,请参阅 Google 的 Maven 代码库。
在应用或模块的 build.gradle
文件中添加所需工件的依赖项:
dependencies { implementation "androidx.constraintlayout:constraintlayout:2.0.4" }
如需详细了解依赖项,请参阅添加构建依赖项。
反馈
您的反馈将帮助我们改进 Jetpack。如果您发现了新问题,或对库的改进有某些建议,请告诉我们。创建新问题前,请先查看此库中的现有问题。您可以点击星标按钮,为现有问题投票。
如需了解详情,请参阅问题跟踪器文档。
版本 2.1
ConstraintLayout 2.1.0 在 MotionLayout 中提供更丰富的功能,并新增了帮助程序(轮播界面等)
版本 2.1.0-alpha2
2020 年 12 月 17 日
发布了 androidx.constraintlayout:constraintlayout:2.1.0-alpha2
。
在此第二个 Alpha 版本中,我们添加了多项新功能:
ConstraintLayout
- android:layout_width 和 android:layout_height 现为可选项,wrap_content 为默认行为
- 新增了 layout_constraintWidth 和 layout_constraintHeight 属性,用于说明尺寸约束
- 支持对约束采用负外边距值
- 支持顶部基线约束和底部基线约束
- 支持基线外边距约束
- 可借助 SharedValues 将外部值注入 ConstraintLayout
MotionLayout
- 支持过冲插值器(anticipate、overshoot)
- 加强了 MotionHelper 支持
- 向 MotionLayout updateStateAnimate(id,cset,duration); 添加了 ConstraintSet 的含动画效果的更新
- 基于共享值的 ViewTransition
- 借助 scheduleTransitonTo,您可以将过渡加入队列,使其在当前过渡完毕后运行。
帮助程序
- 轮播界面现支持无限(环绕)模式
- ReactiveGuide:一项说明如何在 SharedValue 发生变化时自动定位到自身的准则
- MotionEffect:将 Keyframe 注入沿给定方向移动的引用 View 中
- MotionLabel - 用于对单行文本添加动画效果的 View
如需查看有关此版本的更多信息,请点击此处。
版本 2.1.0-alpha1
2020 年 11 月 19 日
发布了 androidx.constraintlayout:constraintlayout:2.1.0-alpha1
。
2.1 版的第一个 Alpha 版本。引入了对以下项目的支持:
- 轮播界面动作帮助程序,用于构建自定义轮播视图
- MotionLayout 场景支持 include 和约束覆盖
- MotionLayout 扩大了对轮播(输入和输出)的支持范围
- MotionLayout 增加了 ViewTransitions,允许对约束集的突变进行单个视图转换
如需查看有关此版本的更多信息,请点击此处。
版本 2.0
ConstraintLayout 2.0 新增了布局功能(虚拟布局等)以及用于简化视图动画的新类 MotionLayout。
版本 2.0.4
2020 年 10 月 29 日
发布了 androidx.constraintlayout:constraintlayout:2.0.4
。
问题修复
此版本修复了在运行时移除子视图的情况下可能会发生的 NPE 问题。建议更新到此版本。
如需查看已解决的问题的列表,请点击此处。
版本 2.0.3
2020 年 10 月 27 日
发布了 androidx.constraintlayout:constraintlayout:2.0.3
。
问题修复
此版本修复了几个问题。建议更新到此版本。
- 窗口边衬区处理
- 某些情况下的尺寸比处理
- 与一些 RTL 布局相关的崩溃问题
如需查看已解决的问题的列表,请点击此处。
版本 2.0.2
2020 年 10 月 6 日
发布了 androidx.constraintlayout:constraintlayout:2.0.2
。
问题修复
此版本改进了性能并修复了几个问题。建议更新到此版本。
- 在某些情况下,对 ConstraintLayout 中视图 GONE 可见性的处理不正确
- 在某些情况下,对 ConstraintLayout 中打包的链的处理不正确
- 修复了流虚拟布局帮助程序在 API 15 上的膨胀异常
- limitsBoundsTo 在 MotionLayout 中被打断
- 在某些情况下,跳转到结尾在 MotionLayout 中被打断(链式转换)
如需查看已解决的问题的列表,请点击此处。
版本 2.0.1
2020 年 8 月 25 日
发布了 androidx.constraintlayout:constraintlayout:2.0.1
。
这是一项次要更新,让您能够在 Android Studio 中使用 MotionEditor。
版本 2.0.0
2020 年 8 月 21 日
发布了 androidx.constraintlayout:constraintlayout:2.0.0
。
问题修复
如需查看已解决的问题的列表,请点击此处。
重要修复包括:
- MotionLayout 转换延迟与 TransitionListener 修复
- ConstraintLayout 流与屏障修复
版本 2.0.0-rc1
2020 年 7 月 29 日
发布了 androidx.constraintlayout:constraintlayout:2.0.0-rc1
。
问题修复
如需查看已解决的问题的列表,请点击此处。
重要修复包括:
- 流修复
- RecyclerView 修复(我们建议更新到 recyclerview 1.2.0 alpha 5 或更高版本)
- MotionLayout TransitionListener 修复
- MotionLayout 内存泄漏修复
版本 2.0.0-beta8
2020 年 7 月 7 日
发布了 androidx.constraintlayout:constraintlayout:2.0.0-beta8
。
问题修复
如需查看已解决的问题的列表,请点击此处。
重要修复包括:
- 占位符行为
- 层可见性
- 流与屏障修复
- TransitionListener 修复
版本 2.0.0-beta7
2020 年 6 月 12 日
发布了 androidx.constraintlayout:constraintlayout:2.0.0-beta7
。
问题修复
如需查看已解决的问题的列表,请点击此处。
重要修复包括:
- MotionLayout 中的嵌套滚动视图问题
- MotionLayout 的转换监听器问题
- MotionLayout 中的内存泄漏
- RecyclerView 问题
- 组可见性
- 内边距问题
版本 2.0.0-beta6
2020 年 5 月 13 日
发布了 androidx.constraintlayout:constraintlayout:2.0.0-beta6
。
问题修复
如需查看已解决的问题的列表,请点击此处。重要修复包括 MotionLayout 中的组可见性处理和派生约束问题。
版本 2.0.0-beta5
2020 年 5 月 7 日
发布了 androidx.constraintlayout:constraintlayout:2.0.0-beta5
。
问题修复
如需查看已解决的问题的列表,请点击此处
版本 2.0.0-beta4
2019 年 12 月 16 日
发布了 androidx.constraintlayout:constraintlayout:2.0.0-beta4
。
新功能
MotionLayout
Transition 中的新属性:
- layoutDuringTransition:可让您配置 MotionLayout 在转换期间应如何响应子级的 requestLayout 调用。可能的值有 {ignoreRequest, honorRequest}
- pathMotionArc:元素移动将采用圆弧路径。可能的值有 {startVertical | startHorizontal | flip | none }
现在,只需省略起始和结束 ConstraintSet 即可定义默认转换。如果找不到其他与当前起始/结束状态匹配的现有转换,则会使用该默认转换。
问题修复
如需查看已解决的问题的列表,请点击此处