4

画面の中心の x 座標と y 座標を取得しようとしています。これが私が試したものです:

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);

画面中央に見えません。誰でもこれで私を助けることができますか?

ありがとう

4

1 に答える 1

4

中心座標を正しく取得していると思いますがsetY、下端の位置を設定していますImageView。私の頭の上から、あなたは次のようなことを試すことができます

SomeImageView.setY(height - SomeImageView.getDrawable().getIntrinsicHeight());
于 2013-08-18T23:07:38.287 に答える