1
我有一個View
,它給我的屏幕座標尊重其父。 我試過getTop()
和getLeft()
的方法來看,仍然不適合我。 我想從主屏幕座標?如何獲得與屏幕相關的視圖座標?
我有一個View
,它給我的屏幕座標尊重其父。 我試過getTop()
和getLeft()
的方法來看,仍然不適合我。 我想從主屏幕座標?如何獲得與屏幕相關的視圖座標?
試試這個,
int[] location = new int[2]; // must be array of two integer.
view.getLocationOnScreen(location);
xAxis = location[0]; //
yAxis = location[1];
嘗試 使用View.getLocationOnScreen()
或getLocationInWindow()
。
例如:
int loc[] = { 0, 0 };
View.getLocationOnScreen(loc);
int x = loc[0]; // x position
int y = loc[1]; // y position