Search code examples
androidtextviewcoordinatespixel

How to get the X Y coordinates and pixel size of a TextView?


Given a TextView, is it possible to know at runtime the X and Y coordinates of where it is drawn? Is it also possible to know the size (width/length) in pixels?


Solution

  • There are getLeft(), getTop(), getWidth(), getHeight() methods for a view, it works for textView too. for more information , see the following link...

    getLeft() and getTop() will return you the starting x,y co-ordinates.

    http://developer.android.com/reference/android/view/View.html