判断当前设备加载多少分辨率的图

设备加载图除了和屏幕的分辨率有关,而且还和设备的物理尺寸有关;	
			DisplayMetrics metrics = new DisplayMetrics();
				getWindowManager().getDefaultDisplay().getMetrics(metrics);
				Log.d("SplashActivity", "xdpi:" + metrics.xdpi);
				Log.d("SplashActivity", "ydpi:" + metrics.ydpi);
				Log.d("SplashActivity", "width pixels:" + metrics.widthPixels);
				Log.d("SplashActivity", "height pixels:" + metrics.heightPixels);
				Log.d("SplashActivity", "densityDpi:" + metrics.densityDpi);


				switch (metrics.densityDpi) {
				case DisplayMetrics.DENSITY_LOW:
					Toast.makeText(this, "L-dip", Toast.LENGTH_SHORT).show();
					break;
				case DisplayMetrics.DENSITY_MEDIUM:
					Toast.makeText(this, "M-dip", Toast.LENGTH_SHORT).show();
					break;
				case DisplayMetrics.DENSITY_HIGH:
					Toast.makeText(this, "H-dip", Toast.LENGTH_SHORT).show();
					break;
				case DisplayMetrics.DENSITY_XHIGH:
					Toast.makeText(this, "xh-dip", Toast.LENGTH_SHORT).show();
					break;
				default:
					Toast.makeText(this, "dip:" + metrics.densityDpi,
							Toast.LENGTH_SHORT).show();


你可能感兴趣的:(判断当前设备加载多少分辨率的图)