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

Not working with EditText #78

Open arundaskv opened 8 years ago

arundaskv commented 8 years ago

Tried to use this with Edittext, since Edittext is extended from TextView, it is expected that the working will be fine. Any help ? I need the same functionality to Views like EditText, RadioButton, CheckBox etc. Can you help me out! Note : Working well with Buttons

amicloud commented 8 years ago

It works fine for me with EditText. Do you have maxLines set to anything? It's been a bit since I messed around with this and I can't check right now, but IIRC you must have maxLines set in order for AutoFit to do anything (makes sense).

Here is an EditText that I have working successfully in one of my apps. Please note, I always use AutoFitTextView by using the AutofitHelper.create(view) method, I do not use the custom view.

Hopefully you aren't still having this problem since this was asked 28 days ago, but if you are I hope that this helps.

<EditText
                android:id="@+id/player1Name"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_margin="1dp"
                android:layout_weight="5"
                android:clickable="true"
                android:enabled="true"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:gravity="center"
                android:hint="@string/playerOne"
                android:lines="1"
                android:longClickable="false"
                android:maxLength="20"
                android:maxLines="1"
                android:padding="0dp"
                android:textColor="@color/material_white"
                android:textColorHint="@color/material_accent"
                android:textSize="20sp"
                android:theme="@style/AppTheme.TransparentCursorBackground" />