How to get number of lines of TextView?

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
    }
});

Leave a Comment