android 获取屏幕的分辨率

android应用开发中,获取屏幕分辨率的代码为:
        Display display = getWindowManager().getDefaultDisplay();
        String lcd_info = "";
        
        /*引用android.util.DisplayMetrics*/
        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        
        width = dm.widthPixels;
        height = dm.heightPixels;
        float density = dm.density;
        lcd_info += "\n" +" 分辨率:" + width + "*" +height;
        lcd_info += "\n" +" 屏幕密度:" + density;
        TextView tv=(TextView)findViewById(R.id.lcd_info); 
		tv.setText(lcd_info);

你可能感兴趣的:(android 获取屏幕的分辨率)