如何Android的屏幕坐标工作?坐标、屏幕、工作、Android

由网友(以我之名,冠伱之姓)分享简介:我的工作与Android 动画,我已经找到了Android坐标系统是相当混乱的,所以我在这里请教一下如何在Android的协调工作这个问题。我下面这个图片移动一个视图到另一个,但现在看来,这是不工作:I am working with Android Animation and I have found the An...

我的工作与Android 动画,我已经找到了Android坐标系统是相当混乱的,所以我在这里请教一下如何在Android的协调工作这个问题。我下面这个图片移动一个视图到另一个,但现在看来,这是不工作:

I am working with Android Animation and I have found the Android coordinate system to be quite confusing so I am here to ask this question about how coordinates work in Android. I am following this image for moving one view to another but it seems it's not working:

推荐答案

此图片presents两个方向(横向/纵向)

要获得MAXX和MAXY,请继续阅读。

To get MaxX and MaxY, read on.

有关Android设备的屏幕坐标,下面的概念会工作。

For Android device screen coordinates, below concept will work.

Display mdisp = getWindowManager().getDefaultDisplay();
Point mdispSize = new Point();
mdisp.getSize(mdispSize);
int maxX = mdispSize.x; 
int maxY = mdispSize.y;

编辑: - 。**支持超过13的Andr​​oid API级可以使用下面code器件

    Display mdisp = getWindowManager().getDefaultDisplay();
    int maxX= mdisp.getWidth();
    int maxY= mdisp.getHeight();

(X,Y): -

(x,y) :-

1)(0,0)是左上角。

2)的(MAXX,0)是右上角

3)(0,MAXY)是左下角

4)(MAXX,MAXY)是右下角

在这里MAXX和MAXY是屏幕最大高度和宽度以像素为单位,这是我们在获取上面给出code。

here maxX and maxY are screen maximum height and width in pixels, which we have retrieved in above given code.

阅读全文

相关推荐

最新文章