Java tutorial
//package com.java2s; import android.content.Context; public class Main { public static int getScreenWidth(Context context) { return (int) ((float) context.getResources().getDisplayMetrics().widthPixels + 0.5f); } }