當父類是ConstraintLayout時
子view設置
android:layout_height="wrap_content"
android:minHeight="40dp"
無效,疑似爲自定義View沒有做minHeight的適配,TextView如此寫就可以實現最小高度的限制
但是如下設置,則可以實現最小高度的效果
android:layout_height="wrap_content"
app:layout_constrainedHeight="true"
app:layout_constraintHeight_min="40dp"
同理寬度只要將height換成width即可
最大寬度/高度效果應該也可以這樣實現
app:layout_constraintHeight_max
我沒測試,請自己嘗試看下