@ SuppressWarnings ( "deprecation" ) @ SuppressLint ( "NewApi" ) public static int getScreenWidth ( Activity context ) { Display display = context . getWindowManager ( ) . getDefaultDisplay ( ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . HONEYCOMB_MR2 ) { Point size = new Point ( ) ; display . getSize ( size ) ; return size . x ; } return display . getWidth ( ) ; }
Get the screen width .