<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/previewLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_height="match_parent"
tools:layout_width="match_parent"
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"
xmlns:fresco="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@+id/contentTextView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:gravity="center"
app:autoSizeMaxTextSize="36sp"
app:autoSizeStepGranularity="4sp"
app:autoSizeTextType="uniform"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent="0.4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="当你觉得别人的生活是完美时,那是因为你不够了解他人。" />
</androidx.constraintlayout.widget.ConstraintLayout>
Adjust app:layout_constraintHeight_percent
programatically.
contentTextView.updateLayoutParams<ConstraintLayout.LayoutParams> { matchConstraintPercentHeight = 0.6f}