Java tutorial
//package com.java2s; import android.content.Context; import android.util.DisplayMetrics; import android.view.Display; import android.view.WindowManager; public class Main { public static int getScreenWidth(Context context) { DisplayMetrics dm = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); display.getMetrics(dm); return dm.widthPixels; } }