Java tutorial
//package com.java2s; import android.app.Activity; import android.content.Context; import android.util.DisplayMetrics; public class Main { /** * This method is responsible to get width of the screen * * @param context * @return */ public static int getWidthOfScreen(Context context) { DisplayMetrics dm = new DisplayMetrics(); try { ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm); } catch (Exception ex) { ex.printStackTrace(); } return dm.widthPixels; } }