前言:
某些情况下,TextView自动换行后,会出现每行结尾处显示不全的问题,
如图:
常见解决方案:
- 设置TextView的“ellipsize”属性为“end” 实测无效!
- 将TextView外部的Layout改为RelativeLayout 实测无效!
- 自定义TextView 过于繁琐且影响性能!
实际解决方案:
只需要设置TextView一个属性就可以解决,这个属性比较冷门:breakStrategy 意为换行策略,
将breakStrategy设置为“balanced”成功解决问题
代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
andr