android-autofittextview icon indicating copy to clipboard operation
android-autofittextview copied to clipboard

Issue with using inside listview

Open jagatappv opened this issue 9 years ago • 4 comments

Hey,

I have used this library.

Its working fine if i am using in any view.

But when i integrate this library with list view. It changing text size randomly.

Let me add my code here, I have added this code inside my list item.

                         <me.grantland.widget.AutofitTextView
                        android:id="@+id/tvAudience"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:layout_gravity="center_vertical"
                        android:text="Publifhbgdfgdfgfggfgc"
                        android:maxWidth="@dimen/max_width_targetaudience"
                        android:singleLine="true"
                        android:textColor="@color/blue_text" />

Can anyone help me to resolve this issue?

Thanks

jagatappv avatar Apr 15 '15 16:04 jagatappv

This is could possible be due to view recycling. Could you post some ListView + Adapter code that repros this issue?

grantland avatar Jul 09 '15 05:07 grantland

Bump. Anybody can reproduce it with a simple ListView/RecyclerView and an Adapter.

noder123 avatar Jul 15 '15 18:07 noder123

This happens when you're layout_width is wrap_content. Changing it to match_parent fixed it for me. It has to know how big to be able to draw it. And for some reason after it's recycled, it keeps the old width.

cranberyxl avatar Aug 12 '15 19:08 cranberyxl

@cranberyxl, thanks a lot! Your solution also helped me :)

gang018 avatar Sep 08 '15 09:09 gang018