android获取屏幕宽高的两种方法

Display display = getWindowManager().getDefaultDisplay(); 

Log.i("view" , "height:" +display.getHeight()); 
Log.i("view" , "width:" +display.getWidth());

DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
Log.i("view" , "height" +displayMetrics.heightPixels); 
Log.i("view" , "width" +displayMetrics.widthPixels);

你可能感兴趣的:(android)