ConstraintLayout使用总结

2023-10-27

0dp的使用

        app:layout_constrainedWidth="true"
        android:layout_width="wrap_content"
        android:layout_width="0dp"

效果是一样的,可以自动充满剩余空间

  • 例子一
    在这里插入图片描述
    我们上图如上设置,左右margin是无效的,需要加上layout_constrainedWidth,如下图
    在这里插入图片描述
    我们也可以把layout_width设置成0dp,文字长的时候,正常,短的时候,我们希望是居中的,就不对了。
    在这里插入图片描述

在这里插入图片描述

  • 例子二
    在这里插入图片描述
    本来想的是,让tv_name在,parent和barrier之间展示,内容长的话,结果就变成上图那样了,完全没达到效果。应该改成layout_width=“0dp”

多控件居中显示

ConstraintLayout 实现多个控件居中显示

ConstraintLayout布局中使用include引用布局,约束属性不起作用

问题:使用约束布局时,再使用include引用布局,造成约束的一些属性没有起作用。
解决方案:重写 android:layout_width、android:layout_height 这两个属性。
在这里插入图片描述

margin使用的问题

大家在使用的时候,有没有遇到过margin有时有效有时无效的问题呢?这个其实是和相对谁有关系的。

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:fresco="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/ll_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/bg_color">

    <View
        android:id="@+id/view_outside_bg"
        style="@style/msg_box_top_outside_bg"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent" />

    <com.sohu.sohuvideo.ui.template.vlayout.view.CircleIconWithIdentityLayout
        android:id="@+id/rc_user_container"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginTop="@dimen/dp_18"
        android:layout_marginLeft="@dimen/dp_15"
        android:layout_width="@dimen/dp_40"
        android:layout_height="@dimen/dp_40" />

    <LinearLayout
        android:id="@+id/right_part"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        style="@style/msg_box_content_container"
        android:orientation="vertical"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintLeft_toRightOf="@+id/rc_user_container"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toTopOf="@+id/rl_content">

        <!--顶部-->
        <include layout="@layout/layout_feed_msg_user_info" />

        <TextView
            android:id="@+id/tv_comment_reply_content"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dp_8"
            android:textColor="#FF1A1A1A"
            android:lineSpacingExtra="4dp"
            android:textSize="15sp"
            tools:text="一个人至少拥我都挖掘的骄傲我的家哇哦就打我至少拥我都挖掘的骄傲我的家哇哦就打我打我的 有一个梦想,有一个理由去坚强。心若没有栖息的地方,到哪里都是在流浪。" />

        <ViewStub
            android:id="@+id/vs_feed_msg_comment"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout="@layout/layout_feed_msg_comment" />

    </LinearLayout>

    <RelativeLayout
        android:id="@+id/rl_content"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="@drawable/bg_f2f5f7_corner_3"
        android:paddingTop="8dp"
        android:paddingBottom="8dp"
        android:paddingRight="8dp"
        android:paddingLeft="10dp"
        android:layout_marginRight="@dimen/dp_8"
        app:layout_constraintBottom_toTopOf="@+id/tv_comment_user_action_time"
        app:layout_constraintLeft_toLeftOf="@+id/right_part"
        app:layout_constraintRight_toRightOf="parent">

        <TextView
            android:id="@+id/tv_last_forward_content"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_toLeftOf="@+id/fl_icon"
            android:includeFontPadding="false"
            android:maxLines="2"
            android:ellipsize="end"
            android:gravity="left"
            android:textColor="@color/c_999999"
            android:textSize="@dimen/text_size_13" />

        <RelativeLayout
            android:id="@+id/fl_icon"
            android:layout_width="72dp"
            android:layout_height="40dp"
            android:layout_alignParentRight="true"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="8dp">

            <com.facebook.drawee.view.SimpleDraweeView
                android:id="@+id/iv_icon"
                android:layout_width="72dp"
                android:layout_height="40dp"
                fresco:actualImageScaleType="centerCrop"
                fresco:placeholderImage="@color/c_f2f5f7"
                fresco:roundedCornerRadius="3dp" />

            <TextView
                android:id="@+id/tv_origin_title"
                style="@style/msg_box_content"
                tools:text="内容已删除" />

            <ImageView
                android:id="@+id/iv_play"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:visibility="gone"
                android:scaleType="centerCrop"
                android:src="@drawable/message_icon_play" />
        </RelativeLayout>

    </RelativeLayout>

    <TextView
        android:id="@+id/tv_comment_user_action_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/c_999999"
        android:textSize="12sp"
        tools:text="1分钟前"
        android:layout_marginBottom="@dimen/dp_18"
        android:layout_marginTop="@dimen/dp_8"
        app:layout_constraintLeft_toLeftOf="@+id/right_part"
        app:layout_constraintBottom_toTopOf="@+id/line_bottom"/>

    <View
        android:id="@+id/line_bottom"
        style="@style/common_location_item_divider"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toBottomOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

在这里插入图片描述
tv_comment_user_action_time控件设置了marginTop 8dp,当时实际没有效果,但是mrginBottom是有效的。这是因为,tv_comment_user_action_time的约束是在line_bottom的上面,所以,marginBottom有效。tv_comment_user_action_time本身和rl_content没有约束,所以marginTop无效.

ConstraintSet

    private void changeLineView(boolean isFold) {
        ConstraintSet constraintSet = new ConstraintSet();
        constraintSet.clone(viewSubscribeBinding.constraintContainer);
        if (isFold) {
            constraintSet.connect(R.id.view_line, ConstraintSet.START, R.id.iv_fold, ConstraintSet.START);
        } else {
            constraintSet.connect(R.id.view_line, ConstraintSet.START, R.id.iv_fold, ConstraintSet.END);
        }
        constraintSet.applyTo(viewSubscribeBinding.constraintContainer);
    }

constraintSet.connect(R.id.view_line, ConstraintSet.START, R.id.iv_fold, ConstraintSet.START)
相当于view_line layout_constraintStart_toStartOf iv_fold

Barrier使用遇到的问题

<?xml version="1.0" encoding="utf-8"?>
<com.sohu.sohuvideo.ui.view.CustomLongClickConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:fresco="http://schemas.android.com/apk/res-auto"
    xmlns:rc="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="@color/bg_color"
    android:id="@+id/ll_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="@dimen/dp_15">

    <RelativeLayout
        android:id="@+id/rl_user_container"
        android:layout_width="@dimen/dp_45"
        android:layout_height="@dimen/dp_45"
        android:layout_marginTop="@dimen/dp_18"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toLeftOf="parent">

        <com.sohu.sohuvideo.ui.template.vlayout.view.RCFramLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="1dp"
            rc:top="45dp"
            rc:bottom="45dp">
            <com.facebook.drawee.view.SimpleDraweeView
                android:id="@+id/iv_user_icon"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                fresco:actualImageScaleType="centerCrop"
                fresco:placeholderImage="@drawable/msg_list_item_user"
                fresco:placeholderImageScaleType="centerInside"
                fresco:roundAsCircle="true" />

        </com.sohu.sohuvideo.ui.template.vlayout.view.RCFramLayout>

        <com.facebook.drawee.view.SimpleDraweeView
            android:id="@+id/iv_user_icon_id"
            android:layout_width="16dp"
            android:layout_height="16dp"
            android:visibility="gone"
            android:layout_alignParentRight="true"
            android:layout_alignParentBottom="true"
            fresco:actualImageScaleType="centerCrop" />

    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/rl_user_action_container"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/dp_10"
        android:layout_gravity="center_vertical"
        android:layout_marginTop="@dimen/dp_18"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toRightOf="@+id/rl_user_container"
        app:layout_constraintRight_toLeftOf="@+id/iv_god">

        <TextView
            android:id="@+id/tv_comment_god_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:includeFontPadding="false"
            android:textColor="@color/c_999999"
            android:textSize="13sp"
            tools:text="恭喜!你的评论已被小编评选为‘神评’,继续加油发布更优质的评论吧恭喜!你的评论已被小编评选为‘神评’,继续加油发布更优质的评论吧" />

    </RelativeLayout>

    <com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/iv_god"
        android:layout_width="70dp"
        android:layout_height="45dp"
        android:layout_centerInParent="true"
        android:contentDescription="@null"
        fresco:actualImageScaleType="centerCrop"
        android:layout_marginLeft="3dp"
        fresco:actualImageResource="@drawable/tag_comments_shenping"
        fresco:placeholderImageScaleType="centerCrop"
        android:layout_marginTop="@dimen/dp_8"
        android:layout_marginRight="@dimen/dp_15"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintLeft_toRightOf="@+id/rl_user_action_container" />

    <androidx.constraintlayout.widget.Barrier
        android:id="@+id/barrier"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:barrierDirection="bottom"
        app:constraint_referenced_ids="rl_user_action_container, iv_god"/>

    <RelativeLayout
        android:id="@+id/rl_comment_origin_content"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="18dp"
        android:background="@drawable/shape_msg_box_my_feed_comment_bg"
        android:padding="10dp"
        android:layout_marginTop="@dimen/dp_6"
        android:layout_marginRight="@dimen/dp_8"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/barrier"
        app:layout_constraintLeft_toLeftOf="@+id/rl_user_action_container">

        <TextView
            android:id="@+id/tv_comment_origin_content"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/c_999999"
            android:layout_toLeftOf="@+id/fl_icon"
            android:layout_centerVertical="true"
            android:maxLines="2"
            android:lineSpacingExtra="3dp"
            android:ellipsize="end"
            android:textSize="13sp"
            tools:text="花落知多少:我来不及认真地年轻,待明白过来时,只能选择认真地老去。或许,我们终究会有那么一天:牵着别人的手,遗忘曾经的他。" />

        <RelativeLayout
            android:id="@+id/fl_icon"
            android:layout_width="72dp"
            android:layout_height="40dp"
            android:layout_alignParentRight="true"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="8dp">

            <com.facebook.drawee.view.SimpleDraweeView
                android:id="@+id/iv_icon"
                android:layout_width="72dp"
                android:layout_height="40dp"
                fresco:actualImageScaleType="centerCrop"
                fresco:placeholderImage="@color/c_e4e7ea"
                fresco:roundedCornerRadius="3dp" />

            <TextView
                android:id="@+id/tv_origin_title"
                style="@style/msg_box_content"
                tools:text="萌宠~萌宠宠萌的一天" />
            <ImageView
                android:id="@+id/iv_play"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:scaleType="centerCrop"
                android:src="@drawable/message_icon_play" />

        </RelativeLayout>

    </RelativeLayout>

    <TextView
        android:id="@+id/tv_comment_user_action_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/c_999999"
        android:textSize="12sp"
        tools:text="1分钟前"
        android:layout_marginTop="@dimen/dp_6"
        android:layout_marginBottom="@dimen/dp_18"
        app:layout_constraintTop_toBottomOf="@+id/rl_comment_origin_content"
        app:layout_constraintLeft_toLeftOf="@+id/rl_user_action_container"
        app:layout_constraintBottom_toTopOf="@+id/line_bottom"/>

    <View
        android:id="@+id/line_bottom"
        style="@style/common_location_item_divider"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"/>

</com.sohu.sohuvideo.ui.view.CustomLongClickConstraintLayout>

在这里插入图片描述
遇到一个奇怪的问题,是Barrier时,文字变成时,Barrier定位的位置总是不对,会导致UI重叠,图片变高就没事。我感觉,是Barrier对文字计算高度支持有问题。
只能换一种解决方案

<?xml version="1.0" encoding="utf-8"?>
<com.sohu.sohuvideo.ui.view.CustomLongClickConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:fresco="http://schemas.android.com/apk/res-auto"
    xmlns:rc="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="@color/bg_color"
    android:id="@+id/ll_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="@dimen/dp_15">

    <RelativeLayout
        android:id="@+id/rl_user_container"
        android:layout_width="@dimen/dp_45"
        android:layout_height="@dimen/dp_45"
        android:layout_marginTop="@dimen/dp_18"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toLeftOf="parent">

        <com.sohu.sohuvideo.ui.template.vlayout.view.RCFramLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="1dp"
            rc:top="45dp"
            rc:bottom="45dp">
            <com.facebook.drawee.view.SimpleDraweeView
                android:id="@+id/iv_user_icon"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                fresco:actualImageScaleType="centerCrop"
                fresco:placeholderImage="@drawable/msg_list_item_user"
                fresco:placeholderImageScaleType="centerInside"
                fresco:roundAsCircle="true" />

        </com.sohu.sohuvideo.ui.template.vlayout.view.RCFramLayout>

        <com.facebook.drawee.view.SimpleDraweeView
            android:id="@+id/iv_user_icon_id"
            android:layout_width="16dp"
            android:layout_height="16dp"
            android:visibility="gone"
            android:layout_alignParentRight="true"
            android:layout_alignParentBottom="true"
            fresco:actualImageScaleType="centerCrop" />

    </RelativeLayout>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/upLayout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/dp_10"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintLeft_toRightOf="@+id/rl_user_container">

        <RelativeLayout
            android:id="@+id/rl_user_action_container"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_marginTop="@dimen/dp_18"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toLeftOf="@+id/iv_god">

            <TextView
                android:id="@+id/tv_comment_god_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:includeFontPadding="false"
                android:textColor="@color/c_999999"
                android:textSize="13sp"
                tools:text="恭喜!你的评论已被小编评选为‘神评’,继续加油发布更优质的评论吧恭喜!你的评论已被小编评选为‘神评’,继续加油发布更优质的评论吧" />

        </RelativeLayout>

        <com.facebook.drawee.view.SimpleDraweeView
            android:id="@+id/iv_god"
            android:layout_width="70dp"
            android:layout_height="45dp"
            android:layout_centerInParent="true"
            android:contentDescription="@null"
            fresco:actualImageScaleType="centerCrop"
            android:layout_marginLeft="3dp"
            fresco:actualImageResource="@drawable/tag_comments_shenping"
            fresco:placeholderImageScaleType="centerCrop"
            android:layout_marginTop="@dimen/dp_8"
            android:layout_marginRight="@dimen/dp_15"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintLeft_toRightOf="@+id/rl_user_action_container"/>

    </androidx.constraintlayout.widget.ConstraintLayout>

    <RelativeLayout
        android:id="@+id/rl_comment_origin_content"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="18dp"
        android:background="@drawable/shape_msg_box_my_feed_comment_bg"
        android:padding="10dp"
        android:layout_marginTop="@dimen/dp_6"
        android:layout_marginRight="@dimen/dp_8"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/upLayout"
        app:layout_constraintLeft_toLeftOf="@+id/upLayout">

        <TextView
            android:id="@+id/tv_comment_origin_content"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/c_999999"
            android:layout_toLeftOf="@+id/fl_icon"
            android:layout_centerVertical="true"
            android:maxLines="2"
            android:lineSpacingExtra="3dp"
            android:ellipsize="end"
            android:textSize="13sp"
            tools:text="花落知多少:我来不及认真地年轻,待明白过来时,只能选择认真地老去。或许,我们终究会有那么一天:牵着别人的手,遗忘曾经的他。" />

        <RelativeLayout
            android:id="@+id/fl_icon"
            android:layout_width="72dp"
            android:layout_height="40dp"
            android:layout_alignParentRight="true"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="8dp">

            <com.facebook.drawee.view.SimpleDraweeView
                android:id="@+id/iv_icon"
                android:layout_width="72dp"
                android:layout_height="40dp"
                fresco:actualImageScaleType="centerCrop"
                fresco:placeholderImage="@color/c_e4e7ea"
                fresco:roundedCornerRadius="3dp" />

            <TextView
                android:id="@+id/tv_origin_title"
                style="@style/msg_box_content"
                tools:text="萌宠~萌宠宠萌的一天" />
            <ImageView
                android:id="@+id/iv_play"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:scaleType="centerCrop"
                android:src="@drawable/message_icon_play" />

        </RelativeLayout>

    </RelativeLayout>

    <TextView
        android:id="@+id/tv_comment_user_action_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/c_999999"
        android:textSize="12sp"
        tools:text="1分钟前"
        android:layout_marginTop="@dimen/dp_6"
        android:layout_marginBottom="@dimen/dp_18"
        app:layout_constraintTop_toBottomOf="@+id/rl_comment_origin_content"
        app:layout_constraintLeft_toLeftOf="@+id/upLayout"
        app:layout_constraintBottom_toTopOf="@+id/line_bottom"/>

    <View
        android:id="@+id/line_bottom"
        style="@style/common_location_item_divider"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"/>

</com.sohu.sohuvideo.ui.view.CustomLongClickConstraintLayout>

ConstrainLayout中使用ViewStub的问题

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ViewStub
                android:id="@+id/vs_flat"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout="@layout/chat_include_flat_emoji"
                android:visibility="gone"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/srf"/>

            <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
                android:id="@+id/srf"
                android:layout_width="0dp"
                android:layout_height="0dp"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintBottom_toTopOf="@+id/vs_flat">

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/conversation_recyclerview"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:paddingTop="@dimen/dp_15"
                    android:clipToPadding="false" />
            </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

            <View
                android:id="@+id/transparent_mask_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/transparent"
                android:visibility="gone" />



        </androidx.constraintlayout.widget.ConstraintLayout>

上面这样写最终运行RecyclerView展示不出来
在这里插入图片描述
如图上面修改一下,rv_flat_emoji id是ViewStub实际引用布局的最外层的id。运行后效果对了,可是IDE标红这里也不对。

最后,改成直接不用ViewStub

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/rv_flat_emoji"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout="@layout/chat_include_flat_emoji"
                android:paddingBottom="@dimen/dp_7"
                android:visibility="gone"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/srf"/>

            <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
                android:id="@+id/srf"
                android:layout_width="0dp"
                android:layout_height="0dp"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintBottom_toTopOf="@+id/rv_flat_emoji">

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/conversation_recyclerview"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:paddingTop="@dimen/dp_15"
                    android:clipToPadding="false" />
            </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

            <View
                android:id="@+id/transparent_mask_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/transparent"
                android:visibility="gone" />



        </androidx.constraintlayout.widget.ConstraintLayout>

参考

约束布局ConstraintLayout看这一篇就够了
哲♂学三幻神带你学习ConstraintLayout(约束布局)
解决ConstraintLayout 与ScrollView 嵌套时ScrollView 内容没有完全显示

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ConstraintLayout使用总结 的相关文章

随机推荐

  • 【译】Filed Play:简介

    引子 在尝试数学函数可视化的时候 发现了一个有趣的库 Field Play 对 README 中的说明进行部分翻译记录 做个初步了解 Origin My GitHub What 让我们为网格上的每个点指定一个向量 1 0 这意味着我们有一个
  • JavaScript Function、函数声明、函数表达式

    JavaScript Function 函数声明 函数表达式 Function 对象 Function 构造器会创建一个新的 Function 对象 在 JavaScript 中每个函数都是一个 Function 对象 使用 Functio
  • 智能指针之unique_ptr(删除器、尺寸)08

    一 unique ptr 1 unique ptr删除器 unique ptr和shared ptr一样 默认删除器都是使用delete 所以当我们创建的是一个数组或者文件这些时 显然delete是无法有效回收的 删除器是一个可调用对象 其
  • 深入分析移动构造函数及其原理

    移动构造函数是C 11中新增加的一种构造函数 其作用是提高程序性能 今天我们就细扒一下它的工作原理 看看它是怎么提高性能的 移动构造函数的由来 在讲解移动构造函数之间 我们先来了解一下在没有移动构造函数之前哪里有性能瓶颈吧 我们来举个例子
  • Node =>Express学习

    1 Express 能做什么 能快速构建web网站的服务器 或 Api接口的服务期 Web网站服务器 专门对外提供Web网页资源的服务器 Api接口服务器 专门对外提供API接口的服务器 2 安装 在项目所处的目录中 运行以下命令 简装到项
  • linux安装jenkins与配置

    简要介绍 jenkins是一个开源软件项目 是基于java开发的一种持续集成工具 用于监控持续重复的工作 旨在提供一个开放易用的软件平台 使软件的持续集成变成可能 语言 Java 一句话描述 持续集成工具 CentOS 7 6 1 安装Op
  • 6 个以假乱真的AI自动配音工具介绍

    6 个以假乱真的AI自动配音工具介绍 用 AI 重新配音 完美骗过各大视频平台的原创保护机制 但这个机器声音味儿太冲 而类似的声音已经快把全国人民包围了 家人们藏不住了 完了芭比Q了 这个男人叫小帅 这个男人叫小美 所以我们很想盘点一下 这
  • 进化优化算法--第二章:爬山法

    算法2 1 最快上升爬山法 x0 lt 随机生成的个体 while not 终止准则 计算x0的适应度f x0 For 每一个解的特征 q 1 2 n xq lt x0 用一个随机变异替换xq的第q个特征 计算xq的适应度f xq 获取下一
  • ChatGPT-4下周要来了

    昨天的一则新闻引起了轰动 微软德国首席技术官 Andreas Braun 在最近一次名为 AI in Focus Digital Kickoff 的活动中透露了这一消息 根据 Braun 的说法 我们将在下周推出 GPT 4 我们将拥有多模
  • npm ERR! code EINTEGRITY npm ERR! sha1-BO3IiUkrA6RF56xm6SJqcBdcqKA= integrity checksum failed when u

    npm ERR code EINTEGRITY npm ERR sha1 BO3IiUkrA6RF56xm6SJqcBdcqKA integrity checksum failed when using sha1 wanted sha1 B
  • 基于 MATLAB 的时间卷积神经网络(TCN)数据回归预测

    基于 MATLAB 的时间卷积神经网络 TCN 数据回归预测 时间卷积神经网络 Temporal Convolutional Network 简称 TCN 是一种基于卷积神经网络的模型 可以有效地处理时间序列数据 并具备较强的建模和预测能力
  • 变量键盘读取、数组与声明:read、array、declare

    变量键盘读取 数组与声明 read array declare 1 read root linux read pt variable 参数 p 后面可以接提示符 t 后面可以接等待的 秒数 范例一 让用户通过键盘输入内容 将该内容变成ate
  • Jdbc 连接MYSQL数据库代码模块

    获得数据库连接的四个步骤 Class for com mysql cj jdbc Driver 由于使用的是MYSQL 8 所以必须要使用相应的驱动 相比于mysql connector java 5 1 47 tar 在jar包中Driv
  • Grafana图表配置快速入门

    1 Grafana图表配置快速入门 前面我们使用 Prometheus Grafana 实现了一个简单的 CPU 使用率变化图 但是这个图还有许多缺陷 例如 左边栏的数值太小了无法调整 下面的图标信息无法定制化等等 其实 Grafana 的
  • ifconfig出现command not found解决办法

    问题 说下我linux配置情况 不一样的可以选择借鉴我的办法 在虚拟机中以最小化方式安装centos7 ifconfig命令无效 而且在sbin目录中没有ifconfig文件 原因 这是因为centos7已经不适用ifconfig命令了 已
  • vue监听一个对象的多个属性

    可以分开监听 但是不能深度监听 不能监听对象 只能 监听属性 如果监听对象 直接在handler外层加上对象名就可以了 下面加deep和immediate都为true watch lineType t console log t rowTy
  • RT-Thread记录(十四、I/O 设备模型之ADC设备)

    RT Thread ADC 设备学习使用 目录 前言 一 ADC 采样基础 1 1 ADC 通道 1 2 ADC 分辨率 1 3 ADC 采样计算 二 ADC 设备操作函数 2 1 查找 ADC 设备 2 2 使能 关闭 ADC 通道 2
  • 前端工程化:express服务端开发

    目录 1 express基本使用 1 安装依赖 2 创建服务 3 启动服务 2 express中间件和异常 1 中间件分3种 2 异常捕获有3种 3 https服务和静态服务 1 https服务 2 静态服务 1 express基本使用 1
  • 揭秘-只有13台DNS根域名服务器原因

    引言 什么是DNS DNS服务 将主机名映射成IP地址 一个主机可以有一个规范主机名 多个别名 www sina com就是个别名 邮件服务器也有别名 目的 负载平衡 通过IP分流 DNS的架构 前面我们说DNS是将主机名对应到IP 那么这
  • ConstraintLayout使用总结

    0dp的使用 app layout constrainedWidth true android layout width wrap content android layout width 0dp 效果是一样的 可以自动充满剩余空间 例子一