Galaxy Note分辨率
问题描述:
我说的是设备分辨率不是屏幕尺寸。Galaxy Note分辨率
我看到很多以前的问题的答案是像320 x480,我认为这是屏幕尺寸。纠正我,如果我错了。
例如,Samsung Galaxy Note Resolution是1280 x 800像素。
如何在java编程中获得此值?
答
800x1280px是根据http://www.phonegg.com/compare/27/Samsung-I9100-Galaxy-S-II-vs-Samsung-Galaxy-Note.html
解决这个问题,应该告诉你如何得到解决。 Get screen dimensions in pixels
答
试试这个
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth(); // deprecated
int height = display.getHeight(); // deprecated
Log.d("hai",width+"");
Log.d("hai",height+"");
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
double x = Math.pow(width/dm.xdpi,2);
double y = Math.pow(height/dm.ydpi,2);
double screenInches = Math.sqrt(x+y);
Log.d("hai","Screen inches : " + screenInches+"");
答
使用这个简单的代码来获取分辨率。
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height= display.getHeight();
TextView w=(TextView)findViewById(R.id.textView2);
w.setText(""+width);
TextView h=(TextView)findViewById(R.id.textView4);
h.setText(""+height);