get Screen Width via DisplayMetrics - Android android.app

Android examples for android.app:Screen

Description

get Screen Width via DisplayMetrics

Demo Code

import android.content.Context;
import android.util.DisplayMetrics;

public class Main {

  public static int getScreenWidth(Context context) {
    DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
    return displayMetrics.widthPixels;
  }/*from w  ww  .ja  v a  2 s.c  o m*/

}

Related Tutorials