How to get number of lines of TextView?

前端 未结 10 2475
萌比男神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

    As mentioned in this post,

    getLineCount() will give you the correct number of lines only after a layout pass.

    It means that you need to render the TextView first before invoking the getLineCount() method.

提交回复
热议问题