android - 具有自定义视图的 ConstraintLayout 作为回收站中的项目
问题描述
似乎 aConstraintLayout
是 a 的改进版本RelativeLayout
。我想知道,如果我有自定义视图(比如说线性布局但不是太嵌套),使用 aConstraintLayout
并将这些自定义视图显示在布局中的某个位置,特别是对于 recyclerview 中的项目,这是一种不好的做法吗?
解决方案
我会说是的 - 当您使用 constrainLayout 时,主要目的是保持视图层次结构平坦并避免嵌套视图组。
所以尽量不要将嵌套视图组添加到您的约束布局(如 relativeLayout、线性等)。
使用 constraintLayuout,将您的 customView 从 linearLayout 迁移到 constraintLayout 非常容易,这样做可以保持平面视图层次结构 - 没有额外的计算(如使用android:weightSum
and时在 linearLayout 中layout_weight
)并且您的布局将加载得更快。
推荐阅读
- r - 解决“if (obs <= ei) 2 * pv else 2 * (1 - pv) 中的错误:需要 TRUE/FALSE 的缺失值”R 中的猿包 Moran 的 I 函数
- google-sheets - Google Sheets IMPORTRANGE 功能:如何找到与我的源相关联的文档?
- http - 在 Iframe 中提交表单时 CSRF 失败
- javascript - airtable:TypeError:无法读取在 JEST 中运行的未定义的属性“绑定”
- python - 将字符串转换为数据框
- ubuntu - 在终端中设置每个目录背景
- python - 在 YAML 中操作环境变量
- css - 如何将文本分隔到 flex-box 中的新行中?
- python - 地球上最小/最简单数据的梯度下降问题
- assembly - 如何在汇编中将 20 位数字存储到 64 位寄存器