View.getLocationOnScreen()返回View的X和Y坐标。
单位是像素还是DIP? 原产地在哪里? 左上方? 该位置指的是View的哪个角落? 轴走哪条路? 例如,320x480屏幕的四个角的坐标是什么?View.getLocationOnScreen() returns the X and Y coordinates of a View.
Are the units pixels, or DIPs? Where is the origin? Top left? Which corner of the View does the location refer to? Which way do the axes go? e.g. what are the coordinates of the four corners of a 320x480 screen?最满意答案
getLocationOnScreen()返回相对于屏幕的坐标(您可以将其视为绝对位置)。 它们以像素为单位,原点是左上角,X轴向右增加,Y轴向下增加到任何方向(纵向或横向)都是如此。 在320x480的屏幕上,它们是:
左上角= 0,0 左下角= 0,480 右上角= 320,0 右下角320,480另一个方法getLocationInWindow()返回相对于父窗口的坐标(比如一个对话框,或类似的东西)。 坐标系不会改变,但范围的范围取决于视图所包含的窗口大小。
getLocationOnScreen() returns coordinates relative to the screen (you can think of this as absolute position). They are in pixels, the origin is top left, X axes increases to the right, and Y axes increases to down that's true for either orientation (portrait or landscape). On a screen that is 320x480 they are:
top left = 0, 0 bottom left = 0, 480 top right = 320, 0 bottom right 320, 480The other method getLocationInWindow() returns coordinates relative to the parent window (say a dialog, or something like that). The coordinate system doesn't change, although the extents of what the range is depends on the size of the window your view is contained within.
更多推荐
发布评论