get Screen Size - Android Phone

Android examples for Phone:Screen

Description

get Screen Size

Demo Code


//package com.java2s;

import android.content.Context;

import android.util.DisplayMetrics;

public class Main {
    static public float[] getScreenSize(Context cxt) {
        float size[] = new float[2];
        DisplayMetrics metrics = cxt.getResources().getDisplayMetrics();
        size[0] = metrics.widthPixels;/*from  w  ww  . jav  a  2 s.  c  o m*/
        size[1] = metrics.heightPixels;
        return size;
    }
}

Related Tutorials