4
我想獲得屏幕中心的x和y座標。這裏是我的嘗試:如何在android中獲取屏幕的中心座標?
Display display = getWindowManager().getDefaultDisplay();
final Point size = new Point();
display.getSize(size);
height = size.y;
float centerY=height/2;//i expect this is the y coordinate of center
但是,這並不工作,當我說:
SomeImageView.setY(centerY);
我沒有看到它在屏幕的中央。誰能幫我這個?
感謝
謝謝你,這工作,但它是設置在頂部邊緣,而我們並不需要劃分的內在高度鮑二,我指的是以下工作: SomeImageView.setY((height - SomeImageView.getDrawable()。getIntrinsicHeight())); – yrazlik
是的,我通常需要一些試驗和錯誤,很高興你想出來:)(我正在糾正我的答案) – ssantos