Android examples for android.app:Screen
get Screen Horizontal Size
import android.content.Context; import android.view.ViewGroup; public class Main { private static final int STANDARD_WIDTH = 720; @SuppressWarnings("deprecation") public static int getHorizontalSize(Context context, int width) { if (width == ViewGroup.LayoutParams.MATCH_PARENT || width == ViewGroup.LayoutParams.WRAP_CONTENT) { return width; } else {//from w w w.j ava 2 s.com return (getDisplayWidth(context) * width) / STANDARD_WIDTH; } } public static int getDisplayWidth(Context context) { return context.getResources().getDisplayMetrics().widthPixels; } }