get Screen size in Pixel - Android android.app

Android examples for android.app:Screen

Description

get Screen size in Pixel

Demo Code

import android.app.Activity;
import android.util.DisplayMetrics;

public class Main{

    public static int[] getScreenPix(Activity act) {
        DisplayMetrics dm = new DisplayMetrics();
        act.getWindowManager().getDefaultDisplay().getMetrics(dm);
        int[] pixs = { dm.widthPixels, dm.heightPixels };
        return pixs;
    }//ww  w .  ja  va2  s .c o  m

}

Related Tutorials