将ConstraintLayout的宽度设置为match_parrent

问题描述 投票:0回答:1

我希望我的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>

结果Result Image

android xml android-layout android-constraintlayout
1个回答
1
投票

您的ConstraintLayout与其父项匹配,而其父项又是LinearLayout。如果要ConstraintLayout弯曲到整个屏幕,请更改此:

android:layout_height="wrap_content"

至此:

android:layout_height="match_parent"
© www.soinside.com 2019 - 2024. All rights reserved.