grantland / android-autofittextview

A TextView that automatically resizes text to fit perfectly within its bounds.
Apache License 2.0
4.27k stars 688 forks source link

It just doesn't work #87

Closed lozohcum closed 7 years ago

lozohcum commented 7 years ago

My textView keeps resizing no matter what I try. I've made simple calculator but my last issue is that when I type long numbers, the text boxes for input and result change their size and become higher and higher and entire layout below moves out of screen http://i.imgur.com/rgfuDLA.png (image at the bottom)

This my my layout: <?xml version="1.0" encoding="UTF-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorPrimaryDark">

<TableLayout
    android:id="@+id/mainTable"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerHorizontal="true">

    <LinearLayout android:orientation="horizontal">

        <TextView style="@style/calcText"
            android:id="@+id/textBox1"
            android:layout_weight=".30"
            android:text="" />

        <TextView style="@style/calcText"
            android:layout_weight=".70"
            android:id="@+id/result"
            android:text=""/>

    </LinearLayout>

    <TableRow>

        <Button style="@style/appButton"
            android:id="@+id/clear"
            android:text="C"/>

        <Button style="@style/appButton"
            android:id="@+id/divide"
            android:text="/"/>

        <Button style="@style/appButton"
            android:id="@+id/multiple"
            android:text="X"/>

        <ImageButton style="@style/appButton"
            android:id="@+id/backspace"
            android:src="@drawable/ic_backspace_black_24dp"
            android:padding="26dp"/>
    </TableRow>

    <TableRow>

        <Button style="@style/appButton"
            android:id="@+id/seven"
            android:text="7"/>

        <Button style="@style/appButton"
            android:id="@+id/eight"
            android:text="8"/>

        <Button style="@style/appButton"
            android:id="@+id/nine"
            android:text="9"/>

        <Button style="@style/appButton"
            android:id="@+id/minus"
            android:text="-"/>
    </TableRow>

    <TableRow>

        <Button style="@style/appButton"
            android:id="@+id/four"
            android:text="4"/>

        <Button style="@style/appButton"
            android:id="@+id/five"
            android:text="5"/>

        <Button style="@style/appButton"
            android:id="@+id/six"
            android:text="6" />

        <Button style="@style/appButton"
            android:id="@+id/plus"
            android:text="+"/>
    </TableRow>

    <TableRow>

        <Button style="@style/appButton"
            android:id="@+id/one"
            android:text="1"/>

        <Button style="@style/appButton"
            android:id="@+id/two"
            android:text="2"/>

        <Button style="@style/appButton"
            android:id="@+id/three"
            android:text="3"/>

        <Button style="@style/appButton"
            android:id="@+id/equals"
            android:text="="
            android:background="@color/active"/>
    </TableRow>

    <TableRow>

        <Button style="@style/appButton"
            android:id="@+id/zero"
            android:text="0"/>

        <Button style="@style/appButton"
            android:id="@+id/dot"
            android:text="."/>
    </TableRow>

</TableLayout>

` screenshot_2017-05-25-13-51-22

lozohcum commented 7 years ago

android:singleLine="true"

was the key to the issue.

however it's deprecated, use

android:maxLines="1"

insead