gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:58:05 24 4
gpt4 key购买 nike

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

在这个 TextView 中,我在不同的位置有两个词,我必须在它们上面放置一个空白布局,这将给它一个玻璃效果。

我可以通过将 textview 放在 framelayout 中并将布局放在它上面来做到这一点。

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

enter image description here

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

最佳答案

这对你有帮助

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

参见 this代码,this链接,还有 this链接。

关于android - 查找放置在 TextView 上的字母的坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11472944/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com