End TextView with 3 dots with use of maxLength

前端 未结 11 896
北海茫月
北海茫月 2020-12-13 06:08

I have a TextView in my layout which is wrap_content in layout_width. It is limited to maximum of 15 characters so I\'m using maxLength.

I need to end this TextView

11条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 06:30

    I needed to do this with Radio Button and I wanted to limit the size to one line. When I used Android:singleline="true", radio button's check circle disappeared. Here's the code that finally worked:

    android:ellipsize="end"
    android:maxLines="1"
    

    There's no need to set ems. This will probably work also in TextView and other UI components. Hope this helps to someone.

提交回复
热议问题