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.
我是 android 新手,我想修复一个相对于另一个按钮的弹出对话框。我正在使用代码膨胀弹出窗口。我怎样才能获得按钮的当前位置,以便我可以使用这些值来膨胀弹出窗口。
这是我用来获取任何View对象的当前 x/y 坐标的代码:
View
/** * @return the absolute x and y coordinates of the given view */ public Point currentPosition(View view) { int[] loc = new int[2]; view.getLocationOnScreen(loc); return new Point(loc[0], loc[1]); }