atom feed2 messages in com.googlegroups.android-developersRe: Dialog Size and Location
FromSent OnAttachments
wrightjmfJan 15, 2008 11:35 am 
hackbodJan 15, 2008 11:40 pm 
Subject:Re: Dialog Size and Location
From:hackbod (hack@gmail.com)
Date:Jan 15, 2008 11:40:21 pm
List:com.googlegroups.android-developers

You can call getWindow().getAttributes() to retrieve the WindowManager.LayoutParams for the window. This has the following fields involving window placement:

http://code.google.com/android/reference/android/view/ViewGroup.LayoutParams.html#width http://code.google.com/android/reference/android/view/ViewGroup.LayoutParams.html#height http://code.google.com/android/reference/android/view/WindowManager.LayoutParams.html#gravity http://code.google.com/android/reference/android/view/WindowManager.LayoutParams.html#x http://code.google.com/android/reference/android/view/WindowManager.LayoutParams.html#y

After making your desired changes, use getWindow().setAttributes() to install the new values.

Note that, though you can force a specific size through the width and height fields, in general the correct way to do this is let the window do its normal layout and determine the window size automatically that way. If you have a single view in the dialog that wants a fixed size such as 300x200, implement View.onMeasure() to call setMeasuredDimension(300, 200). Then when the view hierarchy layout happens, the dialog window will be given a size that ensures your view is that dimension (probably making the actual window larger to take into account the dialog frame and decoration).

http://code.google.com/android/reference/android/view/View.html#onMeasure(int,%20int)

On Jan 15, 11:35 am, wrightjmf <wrig@gmail.com> wrote:

Can anyone tell me how to change the size and location of a dialog box? I have created an activity with its theme attribute set to "@android:style/Theme.Dialog", but I can't figure out how to change the size and location of the resulting dialog.

Any help is appreciated.