Auto Scale TextView Text to Fit within Bounds

后端 未结 30 2657
囚心锁ツ
囚心锁ツ 2020-11-21 05:49

I\'m looking for an optimal way to resize wrapping text in a TextView so that it will fit within its getHeight and getWidth bounds. I\'m not simply looking for

30条回答
  •  有刺的猬
    2020-11-21 05:56

    A workaround for Android 4.x:

    I found AutoResizeTextView and it works great on my Android 2.1 emulator. I loved it so much. But unfortunately it failed on my own 4.0.4 cellphone and 4.1 emulator. After trying I found it could be easily resolved by adding following attributes in AutoResizeTextView class in the xml:

    android:ellipsize="none"

    android:singleLine="true"

    With the 2 lines above, now AutoResizeTextView working perfectly on my 2.1 & 4.1 emulators and my own 4.0.4 cellphone now.

    Hope this helps you. :-)

提交回复
热议问题