如何获得TextView的X Y坐标和像素大小? [英] How to get the X Y coordinates and pixel size of a TextView?

查看:249
本文介绍了如何获得TextView的X Y坐标和像素大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出一个TextView,是否有可能在运行时知道绘制位置的X和Y坐标? 还可以知道以像素为单位的大小(宽度/长度)吗?

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?

推荐答案

视图有getLeft()getTop()getWidth()getHeight()个方法,它也适用于textView.有关更多信息,请参见以下链接...

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

getLeft()getTop()将返回x,y的起始坐标.

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

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

这篇关于如何获得TextView的X Y坐标和像素大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆