Display_获取屏幕宽高

 public static void intScreen(Activity mLauncher){
        //1
        DisplayMetrics displayMetrics = mLauncher.getResources().getDisplayMetrics();
        width = displayMetrics.widthPixels;
        height = displayMetrics.heightPixels;
        midXOfScreen = width / 2.0f;
        midYOfScreen = height / 2.0f;
        
        /*//2
        DisplayMetrics dm = new DisplayMetrics();
        mLauncher.getWindowManager().getDefaultDisplay().getMetrics(dm);
        width = dm.widthPixels;
        height = dm.heightPixels;
        
        //3
        Display display = mLauncher.getWindowManager().getDefaultDisplay();
        width = display.getWidth();
        height = display.getHeight();*/
    }

你可能感兴趣的:(java)