Set Dialog width - Android User Interface

Android examples for User Interface:Dialog

Description

Set Dialog width

Demo Code


//package com.java2s;
import android.app.Dialog;
import android.util.DisplayMetrics;
import android.view.WindowManager;

public class Main {

    public static void SetDialogw(Dialog dialog, WindowManager windowManager) {
        DisplayMetrics dm = new DisplayMetrics();
        windowManager.getDefaultDisplay().getMetrics(dm);
        WindowManager.LayoutParams params = dialog.getWindow()
                .getAttributes();//w  ww .j a v  a 2s  . co  m
        params.width = dm.widthPixels;
        dialog.getWindow().setAttributes(params);
    }
}

Related Tutorials