android constraint layout flow force second element below before its basically hidden

Viewed 243

I have a flow with two buttons in it, sometimes both are shown and sometimes only one. but I can't seem to get all 3 possible outcomes

1st side by side this works fine

2nd one visible one gone this works fine as well, it takes up the entire width which I want

3rd second button is now squished too much I would like it to be pushed down before it basically goes off screen or this but I also have to switch the first one to wrap_content in order to make it wider.

edit: what I want the 3rd to do in the end enter image description here

I would like the above to happen before the 3rd screenshot happens.

is there a way to get all 3 possibilities?

    <androidx.constraintlayout.helper.widget.Flow
        android:id="@+id/flow"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:flow_wrapMode="chain"
        android:layout_marginTop="@dimen/margin_extra_huge"
        app:constraint_referenced_ids="positiveButton, negativeButton"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/dialogMessage" />

    <Button
        android:id="@+id/positiveButton"
        android:layout_width="0dp"
        android:minWidth="50dp"
        android:paddingStart="@dimen/margin_large"
        android:paddingEnd="@dimen/margin_large"
        android:layout_height="match_parent"
        tools:ignore="MissingConstraints"
        tools:text="no, continue" />

    <Button
        android:id="@+id/negativeButton"
        android:layout_width="0dp"
        android:minWidth="50dp"
        android:layout_height="wrap_content"
        android:visibility="visible"
        app:buttonColor="@color/text_color_tertiary"
        app:hasBorder="false"
        tools:ignore="MissingConstraints"
        tools:text="@string/close_confirmation_dialog_close_button"
        tools:visibility="visible" />
0 Answers
Related