get Width Pixels - Android android.graphics

Android examples for android.graphics:Pixel

Description

get Width Pixels

Demo Code

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

public class Main{

    public static int getWidthPixels(Activity activity) {
        DisplayMetrics dm = new DisplayMetrics();
        activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
        return dm.widthPixels;
    }/*from   w  w w.  j  a  v a2  s .c  o m*/

}

Related Tutorials