How to update constraints after scale a view in Android ConstraintLayout

Viewed 1326

enter image description here

enter image description here

enter image description here

Update: I just used setTextScaleX instead of setScalex to scale the textView and it worked as what I expected this time.

Just like the photos above. I use ConstraintLayout to keep the space between "$" and center textView and "00". When I set 5555 to the center textView, it became wider, but I want to keep its original size. So I scaled the "5555" part, I found the constraints did not update as well. Can anybody give me some advice? Thanks a lot!

My layout xml is as following.

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.echo.tipcalculator.fragments.FeeUnitFragment">

    <TextView
        android:id="@+id/fee_title"
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="16dp"
        android:text="title"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginStart="16dp" />

    <TextView
        android:id="@+id/fee_unit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="$"
        android:textSize="20dp"
        android:layout_marginTop="8dp"
        app:layout_constraintTop_toBottomOf="@+id/fee_title"
        app:layout_constraintLeft_toLeftOf="@+id/fee_title" />

    <TextView
        android:id="@+id/fee_main"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp"
        android:clickable="true"
        android:ellipsize="end"
        android:gravity="top"
        android:includeFontPadding="false"
        android:maxLines="1"
        android:text="0"
        android:textSize="80dp"
        app:layout_constraintLeft_toRightOf="@+id/fee_unit"
        app:layout_constraintTop_toTopOf="@+id/fee_unit" />

    <TextView
        android:id="@+id/fee_decimal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="00"
        android:textSize="20dp"
        app:layout_constraintTop_toTopOf="@+id/fee_main"
        app:layout_constraintLeft_toRightOf="@+id/fee_main"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp" />

</android.support.constraint.ConstraintLayout>
0 Answers
Related