ConstraintLayout布局中子控件长宽超出父控件不显示问题

这里写目录标题

问题

layout布局中最外层的父控件是ConstraintLayout布局,接下来有两个子控件,一个是自定义的View控件,一个是ConstraintLayout控件
在这里插入图片描述但是子控件的高度超出了父控件的范围,然后导致不显示。

原因

由于上面的控件时一个空白的画板,下面的控件是有具体内容的控件,所以主要问题是出在了上面空白画板的控件属性上面。
画板控件的高度不管是设置wrap还是match,都是有效果的。

解决方法

上面控件的属性:高度应该设置为0dp,然后设置专有的上下左右对齐

<com.view.SignatureView
        android:id="@+id/signature_view"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toTopOf="@+id/bottom_button"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />

在这里插入图片描述
ok,布局达到了我想要的结果。

猜你喜欢

转载自blog.csdn.net/jxj960417/article/details/130749065