Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use getlinecount() in textview android

i want to know how many line in my text view. i already set mytextview text, then i want to get how many line it take in mytextview.

i use mytextview.getLineCount() but it didn't work. it always return 0.

can someone helpme.

like image 499
Alfa Avatar asked Jul 13 '12 09:07

Alfa


People also ask

How do I know if my Android ellipsis is applied?

public int getEllipsisCount (int line): Returns the number of characters to be ellipsized away, or 0 if no ellipsis is to take place. So, simply call : int lineCount = textview1.


1 Answers

You need to post method for fetching the lines counts. Here is the sample code

imageCaption.setText("Text Here");
imageCaption.post(new Runnable() {

    @Override
    public void run() {

        int lineCount    = imageCaption.getLineCount();

        Log.v("LINE_NUMBERS", lineCount+"");
    }
});
like image 53
Ayaz Alavi Avatar answered Oct 23 '22 22:10

Ayaz Alavi