Android TextView自动换行文本显示不全解决

前言:

        某些情况下,TextView自动换行后,会出现每行结尾处显示不全的问题,

        如图:

常见解决方案:

  1. 设置TextView的“ellipsize”属性为“end”  实测无效!
  2. 将TextView外部的Layout改为RelativeLayout  实测无效!
  3. 自定义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
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

赵星海(深海呐)

感谢支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值