DanielMartinus / Stepper-Touch

Stepper Touch for Android based on MaterialUp submission
Apache License 2.0
686 stars 83 forks source link

Does not paint properly with constraintlayout 2.0 #52

Open MKevin3 opened 5 years ago

MKevin3 commented 5 years ago

With the current layout the circle around the text spreads across the width. Here is a fix. It uses the spread aspect to make it paint correctly with constraint layout 1.x and 2.x

    <TextView
        android:id="@+id/textViewNegative"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/stepper_side_control_margin_start"
        android:text="@string/stepper_text_negative"
        android:textSize="@dimen/stepper_side_control_text_size"
        app:layout_constraintHorizontal_chainStyle="spread_inside"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toStartOf="@id/viewCounter"
        app:layout_constraintTop_toTopOf="parent" />

    <FrameLayout
        android:id="@+id/viewCounter"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="@drawable/circle"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintDimensionRatio="H,1:1"
        app:layout_constraintStart_toEndOf="@id/textViewNegative"
        app:layout_constraintEnd_toStartOf="@id/textViewPositive"
        app:layout_constraintTop_toTopOf="parent">

        <TextView
            android:id="@+id/viewCounterText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="@string/stepper_text_count"
            android:textColor="@color/stepper_text"
            android:textSize="24sp" />

    </FrameLayout>

    <TextView
        android:id="@+id/textViewPositive"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="@dimen/stepper_side_control_margin_end"
        android:text="@string/stepper_text_positive"
        android:textSize="@dimen/stepper_side_control_text_size"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/viewCounter"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintTop_toTopOf="parent" />
DanielMartinus commented 3 years ago

@MKevin3 hey, thanks for the suggestion. I'm trying to find the issue that you're solving here. Do you have any way I can reproduce it? Making the stepper wider of heigher doesn't seem to show any issues.