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

Using AutofitTextView in widget #36

Open bagbyte opened 9 years ago

bagbyte commented 9 years ago

I'm using AutofitTextView in a LinearLayout (A):

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="60dp"
    android:layout_height="match_parent"
    android:padding="0dp">

    <me.grantland.widget.AutofitTextView
        android:id="@+id/label"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:singleLine="true"
        />

<!-- old code
    <TextView
        android:id="@+id/label"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:singleLine="true"
        /> -->
</LinearLayout>

From my AppWidgetProvider, I'm dynamically adding some linear layout A.

On the device the Widget is not loading, an error is displayed: "Problem loading widget", but I don't see any error on logcat.

grantland commented 9 years ago

Unfortunately I haven't used this library in a Widget before

tibbi commented 8 years ago

i know its an old issue, just saying that there is only a very limited amount of views you can use in a widget. Here is the list http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout . For some reason "me.grantland.widget.AutofitTextView" is not one of them :) In my app Im reusing the same layout in the app activity and the widget, and the view type is a simple TextView. In the app activity I use "AutofitHelper.create(mytextview);" to make it an autofittextview, sadly in the widget i could not make it work. Maybe it helps someone anyway.