屏幕上的安卓文本视图的文本坐标



假设我有一个包含文本的TextView。有可能从TextView中获得屏幕上单词的坐标吗?

来了

TextView tv;
int[] coordinates = new int[2];
tv.getLocationOnScreen(coordinates);
Log.v("Coordinates of my TextView are: ", "Left(X) = "+coordinates[0]+" and Top(Y) = "+coordinates[1]);

希望它有帮助)))实际上,它适用于任何视图,而不仅仅是电视。

我遇到了同样的问题,我已经解决了。您必须在TextView中使用clickableSpan。有关更多详细信息,请参阅我的帖子,如果您有任何问题,请告诉我:)

最新更新