draw text “ellipsized” to a canvas

后端 未结 2 1242
星月不相逢
星月不相逢 2021-01-07 23:38

I need to draw text to a canvas (of a custom view), and need to first trim it to a maximum width, adding an ellipsis at the end if necessary. I see you can do it for a Text

2条回答
  •  梦谈多话
    2021-01-08 00:11

    Take a look at TextUtils.ellipsize(). I think it's exactly what you want. Basically you just tell it the amount of space available and using the other state information it will create the correct text for you. :)

提交回复
热议问题