Auto Scale TextView Text to Fit within Bounds in 4.0

痴心易碎 提交于 2019-12-07 17:12:22

问题


The solution Chase gave for this problem was working fine in 2.2 - 3.2 but when I tested it on 4.0 it failed.

Here is the original post:

Auto Scale TextView Text to Fit within Bounds

On 4.0 I get a strange line spacing problem which brings me to something he/she wrote in his/her code:

// Some devices try to auto adjust line spacing, so force default line spacing 
// and invalidate the layout as a side effect
   textPaint.setTextSize(targetTextSize);
   setLineSpacing(mSpacingAdd, mSpacingMult);

I guess this is failing now and I'm not sure why (anyone?). Also not sure why he/she wrote it in the first place as isn't this OS dependent and not a device dependent problem?


回答1:


ICS has TextView resizing issue where in some conditions it will resize up but not down. This black magic works for me. After you set the text of your TextView, also perform this

textView.append("\uFEFF");


来源:https://stackoverflow.com/questions/8066642/auto-scale-textview-text-to-fit-within-bounds-in-4-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!