寻找一个字母的坐标放置的TextView [英] Finding the coordinates of a letter placed on TextView
问题描述
我有一个包含文本渴望一个TextView,涵盖了屏幕的一半,
在此TextView的我已经在不同的位置两个字上面,我必须把一个空白的布局,这将给它一个玻璃效果。
我可以通过将TextView的一个的FrameLayout,并把布局上面做到这一点。
问题是,我将如何得到的话坐标,因为文本可能会被安排在不同设备上不同的位置。
我要放置在白色标记的地方布局。可有一个人请帮助
谢谢你。
这将是对你有所帮助。
公共无效getLocationOnScreen(INT []位置)
自:API级别1计算在屏幕上该视图的坐标。该参数必须是一个
阵列中两个整数。该方法返回后,该数组包含x和y
位置的顺序。参数
位置的两个整数的数组,其中保持的坐标
块引用>请参阅这个 code,<一个href=\"http://developer.android.com/reference/android/view/View.html#getLocationOnScreen%28int%5B%5D%29\"相对=nofollow>此链接,而且此链接。
I have a textview which contains longs text that covers half of the screen,
In this textview I have two words at different position above which I have to place a blank layout which will give it a glass effect.
I can do this by placing the textview in a framelayout and placing the layout above it.
The problem is how will I get the coordinates of the words, as the text may be arranged at different position on different devices.
I want to place a layout at the place marked white. Can some one please help Thanks.
解决方案This will be helpful for you
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
See this code, this link, and also this link.
这篇关于寻找一个字母的坐标放置的TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!