Monday 20 August 2012

Get number of lines of TextView in android

How to get total number of lines of TextView ?


TextView textView = (TextView)findViewById(R.id.textView1);
int totalLines = textView.getLineCount();


ViewTreeObserver vto = this.textView.getViewTreeObserver();
        vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

            @Override
            public void onGlobalLayout() {
                ViewTreeObserver obs =
textView.getViewTreeObserver();
                obs.removeGlobalOnLayoutListener(this);
                System.out.println(": " +
textView.getLineCount());
               
            }
        });



Related links :

textview in android how get number of lines of textview in android ViewTreeObserver in android get total number of lines of textview get visible lines of textview in android

0 comments:

Post a Comment

Fill free to post your Queries and Suggesion...!

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Bluehost Review