DisplayMetrics (Get the phone screen pixel)
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int widthPixels = dm.widthPixels;
int heightPixels = dm.heightPixels;
float density = dm.density;
int screenWidth = widthPixels * density ;
int screenHeight = heightPixels * density ;
For example
320*480>
widthPixels is 320, heightPixels is 480, density is 1.0。
480*800>
widthPixels is 320, heightPixels is 533, densityis 1.5。
沒有留言:
張貼留言