How do I tell if my textview has been ellipsized?

前端 未结 14 1671
天涯浪人
天涯浪人 2020-11-30 19:31

I have a multi-line TextView that has android:ellipsize=\"end\" set. I would like to know, however, if the string I place in there is actually too

14条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 20:06

    The Kotlin way:

    textView.post {
       if (textView.lineCount > MAX_LINES_COLLAPSED) {
       // text is not fully displayed
       }
    }
    

    Actually View.post() is executed after the view has been rendered and will run the function provided

提交回复
热议问题