get Window Width - Android Phone

Android examples for Phone:Screen

Description

get Window Width

Demo Code


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

import android.util.DisplayMetrics;

public class Main {
    public static int getWindowWidth(Activity activity) {
        DisplayMetrics dm = new DisplayMetrics();
        activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
        return dm.widthPixels;
    }//from   w  ww  .j a va2  s  .  c  om
}

Related Tutorials