我希望我的ContraintLayout宽度与父项匹配,但不起作用。
layout.xml
<LinearLayout
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="wrap_content">
//Other View
<android.support.constraint.ConstraintLayout
android:background="#ff0000"
android:layout_width="match_parent"
android:layout_height="match_parent">
//Child View
</android.support.constraint.ConstraintLayout>
</LinearLayout>
您的ConstraintLayout
与其父项匹配,而其父项又是LinearLayout
。如果要ConstraintLayout
弯曲到整个屏幕,请更改此:
android:layout_height="wrap_content"
至此:
android:layout_height="match_parent"