您的位置:首页 > 移动开发 > Android开发

android获取屏幕分辨率代码

2017-05-14 20:50 281 查看
DisplayMetrics dm = getResources().getDisplayMetrics();  
int width=dm.widthPixels;  
int height=dm.heightPixels;  
double x = Math.pow(width,2);  
double y = Math.pow(height,2);  
double diagonal = Math.sqrt(x+y);  
 
int dens=dm.densityDpi;  
double screenInches = diagonal/(double)dens;  
Log.d("tag","The screenInches "+screenInches); 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: