查找放置在TextView上的字母的坐标

Har*_*560 5 android android-layout

我有一个textview,其中包含覆盖屏幕一半的长文本,

在这个文本视图中,我在上面的不同位置有两个单词,我必须放置一个空白的布局,这将给它一个玻璃效果.

我可以通过将textview放在framelayout中并将布局放在它上面来实现.

问题是如何获得单词的坐标,因为文本可能被安排在不同设备上的不同位置.

在此输入图像描述

我想在标记为白色的地方放置一个布局.有人可以帮忙谢谢.

Avi*_*nku 3

这会对你有帮助

public void getLocationOnScreen (int[] location)
    Since: API Level 1

Computes the coordinates of this view on the screen. The argument must be an
array of two integers. After the method returns, the array contains the x and y
location in that order.

Parameters
   location   an array of two integers in which to hold the coordinates
Run Code Online (Sandbox Code Playgroud)

请参阅代码、链接以及链接。