android约束布局的局限性,android – ConstraintLayout与DimensionRatio结合使用时不考虑最大宽度/高度...

以下观点必须是正方形.我也希望将视图限制在一定的大小.不知何故,当ConstraintLayout与同一元素上的dimensionRatio结合使用时,它忽略了max width / height属性.

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:layout_width="0dp"

android:layout_height="0dp"

app:layout_constraintTop_toTopOf="@+id/guideline_top"

app:layout_constraintDimensionRatio="1:1"

app:layout_constraintLeft_toLeftOf="@+id/guideline_left"

app:layout_constraintRight_toRightOf="@+id/guideline_right"

app:layout_constraintBottom_toBottomOf="@+id/guideline_bottom"

app:layout_constraintWidth_max="100dp"

app:layout_constraintHeight_max="100dp"/>

目前我通过将View放入容器中来使用解决方法,如下所示.但我宁愿保持我的布局层次尽可能平坦.

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:layout_width="0dp"

android:layout_height="0dp"

app:layout_constraintTop_toTopOf="@+id/guideline_top"

app:layout_constraintLeft_toLeftOf="@+id/guideline_left"

app:layout_constraintRight_toRightOf="@+id/guideline_right"

app:layout_constraintBottom_toBottomOf="@+id/guideline_bottom"

app:layout_constraintWidth_max="100dp"

app:layout_constraintHeight_max="100dp">

android:layout_width="0dp"

android:layout_height="0dp"

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintDimensionRatio="1:1"

app:layout_constraintLeft_toLeftOf="parent"

app:layout_constraintRight_toRightOf="parent"

app:layout_constraintBottom_toBottomOf="parent"

/>

这是约束布局中的限制,您不能将最大宽度/高度与尺寸比结合使用吗?

我正在使用ConstraintLayout v1.0.2.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值