可以通过以下代码轻松获取屏幕尺寸
//获取屏幕尺寸
DisplayMetrics metric = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metric);
int mScreenWidth = metric.widthPixels;
int mScreenHeight = metric.heightPixels;
时间: 2024-11-06 03:59:52
可以通过以下代码轻松获取屏幕尺寸
//获取屏幕尺寸
DisplayMetrics metric = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metric);
int mScreenWidth = metric.widthPixels;
int mScreenHeight = metric.heightPixels;