get Dialog Width - Android User Interface

Android examples for User Interface:Dialog

Description

get Dialog Width

Demo Code


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

import android.util.DisplayMetrics;

public class Main {

    public static int getDialogW(Activity aty) {
        DisplayMetrics dm = new DisplayMetrics();
        dm = aty.getResources().getDisplayMetrics();
        int w = dm.widthPixels - 100;
        // int w = aty.getWindowManager().getDefaultDisplay().getWidth() - 100;
        return w;
    }//w  w  w.  ja  v  a 2  s  .  c  om
}

Related Tutorials