2012-05-24 107 views
0

我说的是设备分辨率不是屏幕尺寸。Galaxy Note分辨率

我看到很多以前的问题的答案是像320 x480,我认为这是屏幕尺寸。纠正我,如果我错了。

例如,Samsung Galaxy Note Resolution是1280 x 800像素。

如何在java编程中获得此值?

回答

0

尝试this示例了解如何获取有关设备显示的信息。

3

试试这个

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+""); 
0

使用这个简单的代码来获取分辨率。

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);