If you want to get screen width and height of device in java file you can use DisplayMetrics class . This is a very simple way to get screen size. By using this code you can get size in pixels.
DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int height = displaymetrics.heightPixels; int width = displaymetrics.widthPixels;
In a view you need to do something like this:
((Activity) getContext()).getWindowManager() .getDefaultDisplay() .getMetrics(displayMetrics);