android imagespan image is cut error in singleline textview

后端 未结 2 974
野性不改
野性不改 2021-01-07 10:52

I use ImageSpan to display image in textview. The TextView is sinlgline with end ellipsize. When image is in the end of textview and there is not enought space for it. I thi

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-07 11:32

    I use TextUtils.ellipsize for the text before setting it into TextView.

    CharSequence cs = TextUtils.ellipsize(s, textView.getPaint(), textView.getWidth() - textView.getPaddingRight() - textView.getPaddingLeft(), TextUtils.TruncateAt.END);
    textView.setText(cs);
    

提交回复
热议问题