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

Textsize too large when adding drawable to TextView #50

Open SolomonBier opened 9 years ago

SolomonBier commented 9 years ago

Below is my code in XML that adds a drawable icon to the textview. The text resizes but is always slightly too large for the button. I think this class does not consider the offset from the drawable:

   <me.grantland.widget.AutofitTextView
        android:layout_width="150dp"
        android:layout_height="35dp"
        android:text="VEHICLE"
        android:id="@+id/order_button_vehicle"
        android:textColor="@color/honk_order_help_button"
        android:background="@drawable/order_help_button"
        android:textSize="14sp"
        android:drawableLeft="@drawable/icon_car"
        android:drawableStart="@drawable/icon_car"
        android:drawablePadding="5dp"
        android:paddingLeft="10dp"
        android:paddingBottom="10dp"
        android:paddingRight="10dp"
        android:layout_alignBottom="@+id/order_button_payment"
        android:layout_toRightOf="@+id/centerView"
        android:layout_toEndOf="@+id/centerView"
        android:layout_marginLeft="10dp"
        android:layout_marginStart="10dp"
        android:singleLine="true"
        autofit:minTextSize="6sp"
     />