AutoSizeTextView - VerstSiu/kotlin_extension GitHub Wiki
Fix layout behaviour error for single wrap constranit
case, base on AppCompatTextView
auto size implementation.
API List
<attr name="ktx_autoSizeinTextSize" format="dimension"/>
<attr name="ktx_autoSizeMaxTextSize" format="dimension"/>
<attr name="ktx_autoSizeStepGranularity" format="dimension"/>
<attr name="ktx_autoSizePresetSizes" format="reference"/>
<attr name="ktx_debugEnabled" format="boolean"/>
<declare-styleable name="AutoSizeTextView">
<attr name="ktx_autoSizeMinTextSize"/>
<attr name="ktx_autoSizeMaxTextSize"/>
<attr name="ktx_autoSizeStepGranularity"/>
<attr name="ktx_autoSizePresetSizes"/>
<attr name="ktx_debugEnabled"/>
</declare-styleable>
Usage
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Make sure AutoSizeTextView is the only wrap constraint element -->
<!-- at it's horizontal elements' chain -->
<com.ijoic.ktx.widget.autosize.AutoSizeTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
app:layout_constraintWidth_default="wrap"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:ktx_autoSizeMaxTextSize="28sp"
app:ktx_autoSizeMinTextSize="16sp"/>
</android.support.constraint.ConstraintLayout>