什麼是性差異愨使用下面的代碼,以獲得屏幕寬度和高度的android:錯誤的屏幕寬度和高度
public HorseView(Context context) {
super(context);
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
int height = metrics.heightPixels;
.............
}
,並使用另一個這樣的:
public void surfaceCreated(SurfaceHolder holder) {
thread.setRunning(true);
thread.start();
int height = this.getHeight();
}
誰知道爲什麼在第一種情況下,高度設置爲508;第二種情況是533;
在此先感謝。
我打電話給一個活動之外。 getWindowManager()在那裏不起作用。 –