How to get number of lines of TextView?

前端 未结 10 2486
萌比男神i
萌比男神i 2020-11-28 09:29

I want to get the number of lines of a text view

textView.setText(\"Test line 1 Test line 2 Test line 3 Test line 4 Test line 5.............\")
10条回答
  •  醉话见心
    2020-11-28 10:19

    I was able to get getLineCount() to not return 0 using a post, like this:

    textview.setText(“Some text”);
    textview.post(new Runnable() {
        @Override
        public void run() {
            int lineCount = textview.getLineCount();
            // Use lineCount here
        }
    });
    

提交回复
热议问题