当前位置:网站首页>Use guidelines in constraintlayout to limit the maximum width of controls

Use guidelines in constraintlayout to limit the maximum width of controls

2022-06-11 07:56:00 tinyvampirepudge

ConstraintLayout Use in Guideline Limit the maximum width of the control

Below ll_container The maximum width is limited : The maximum width is the screen width - 88dp.
ll_container Variable width , There is a maximum width limit .

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

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/guideline1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_begin="44dp" />

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/guideline2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_end="44dp" />

    <LinearLayout
        android:id="@+id/ll_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:gravity="center_vertical"
        android:orientation="vertical"
        app:layout_constrainedWidth="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="@id/guideline1"
        app:layout_constraintRight_toRightOf="@id/guideline2"
        app:layout_constraintTop_toTopOf="parent">

        ...
    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
原网站

版权声明
本文为[tinyvampirepudge]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110747210439.html