Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在屏幕上有一个按钮,我想获取该图像的 x 和 y 坐标,通过使用该图像坐标我需要移动图像,帮助我,谢谢
您可以在 onWindowFocusChanged 方法中获取实际大小和位置,这里是您放置代码的地方。
尝试这个:
int[] loc = new int[2]; someView.getLocationOnScreen(loc); //loc[0] - x; //loc[1] - y;