Android: Something better than android:ellipsize=“end” to add “…” to truncated long Strings?

前端 未结 4 1251
予麋鹿
予麋鹿 2020-12-02 15:34

This property makes

\"short and very-long-word\"

to

\"short and\"

. But I want to

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 15:51

    I had a similar problem and setting this property to the TextView helped:

    android:singleLine="true"
    

    Also, I was using a RelativeLayout so I limited the space the TextView could take by setting a left margin to a button to the right of the TextView, so that the text cannot expand further and is forced to truncate its content.

    Maybe it's not the solution to your problem, but it helped me in a similar situation.

提交回复
热议问题