Android examples for User Interface:Screen Size
get Width Ratio
//package com.java2s; import android.content.Context; public class Main { private static Context context; private static boolean phone; private static double widthRatio = 0; public static double getWidthRatio() { if (widthRatio == 0) { widthRatio = getDisplayWidth() / (isPhone() ? 320.0 : 1024.0); }//w w w . j a va 2 s.co m return widthRatio; } public static int getDisplayWidth() { return context.getResources().getDisplayMetrics().widthPixels; } public static boolean isPhone() { return phone; } }