This blog help you to find screen dimensions in pixels programmatically as well as get the screen width and screen height and then set position. You can use DisplayMetrics class. DisplayMetrics class is a structure describing general information about a display, such as its size, density, and font scaling.
To get DisplayMetrics members initialize an object like this:
DisplayMetrics metrics = new DisplayMetrics();
((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics);
// To get actual values for width and height you can call :
int width = metrics.widthPixels;
int height = metrics.heightPixels;
0 Comment(s)