View.getLocationOnScreen()的单位和轴方向是什么?(What are the units and axes directions for View.getLocationOnS

编程入门 行业动态 更新时间:2024-10-22 23:04:27
View.getLocationOnScreen()的单位和轴方向是什么?(What are the units and axes directions for View.getLocationOnScreen ()?)

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, 480

The 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.

更多推荐

本文发布于:2023-04-27 23:56:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1329678.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方向   单位   getLocationOnScreen   View   axes

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!