android获取屏幕分辨率代码

来源:互联网 发布:淘宝多个客服怎么设置 编辑:程序博客网 时间:2024/06/05 21:57
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); 
0 0
原创粉丝点击