Android examples for android.content:Context
get Display Metrics via Context
import android.content.Context; import android.text.TextUtils; import android.widget.TextView; public class Main{ public static int getDisplayMetrics(Context context, int tp) { int pixels = 0; if (tp == 0) { pixels = context.getResources().getDisplayMetrics().widthPixels; } else if (tp == 1) { pixels = context.getResources().getDisplayMetrics().heightPixels; }// w w w. j a va 2s. c o m return pixels; } }