使用下一个代码在 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;
提前致谢。
最佳答案
- 533 * 1.5 = 800。
- 508 * 1.5 = 762。
这两个值的不同是因为通知栏的高度是38px。
关于android - 错误的屏幕宽度和高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13738207/