get Window Size - Android Phone

Android examples for Phone:Screen

Description

get Window Size

Demo Code


//package com.java2s;
import android.app.Activity;

import android.graphics.Point;

import android.util.DisplayMetrics;

public class Main {

    public static Point getWindowSize(Activity activity) {

        DisplayMetrics dm = new DisplayMetrics();
        activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
        return new Point(dm.widthPixels, dm.heightPixels);

    }/*from  w w w.  j  ava2  s .co  m*/
}

Related Tutorials