How do I tell if my textview has been ellipsized?

前端 未结 14 1633
天涯浪人
天涯浪人 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条回答
  • 2020-11-30 20:09

    it is working for me

    if (l != null) {
        int lines = l.getLineCount();
         if (lines > 0) {
         for (int i = 0; i < lines; i++) {
         if (l.getEllipsisCount(i) > 0) {
          ellipsize = true;
          break;
         }
        }
       }
      }
    
    0 讨论(0)
  • 2020-11-30 20:11

    This worked to me:

    textView.post(new Runnable() {
                            @Override
                            public void run() {
                                if (textView.getLineCount() > 1) {
                                    //do something
                                }
                            }
                        });
    
    0 讨论(0)
提交回复
热议问题