Dialog cannot fill whole screen

3836 views
Skip to first unread message

doubleslash

unread,
Jul 31, 2009, 10:33:40 AM7/31/09
to Android Developers
My dialog shows a relativelayout, which is set to fill_parent in both
width and height. However, it doesn't fill the whole screen. I tried
settting the window flags to full screen but that didn't help either.
Can someone tell me how to do this?

nEx.Software

unread,
Jul 31, 2009, 10:41:08 AM7/31/09
to Android Developers
Just out of curiosity, why are you using a dialog if you want it to
fill the screen? That being said, the content within the dialog will
push it to fill the screen if required. Putting things like ListViews
with fill_parent seems to do the trick...

matthias

unread,
Sep 1, 2009, 10:18:04 AM9/1/09
to Android Developers
Hi, I am also trying to find a solution to this...

On Jul 31, 4:41 pm, "nEx.Software" <email.nex.softw...@gmail.com>
wrote:
> Just out of curiosity, why are you using a dialog if you want it to
> fill the screen?

simply because there are occasions where you need to replace content
in the dialog dynamically and you don't want the dialog to resize but
remain at full width and height. For instance, I need to display
images of different width and height in the dialog, and I don't want
the dialog to change size with every image the user looks at.

Dianne Hackborn

unread,
Sep 1, 2009, 12:55:19 PM9/1/09
to android-d...@googlegroups.com
The dialog theme, as part of its nature, sets the top-level window layout to be WRAP_CONTENT.  You could try manually setting the Window layout width and height to FILL_PARENT, though this is going to make for a kind-of weird dialog (especially if one day you find yourself running on a large screen...).
--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

matthias

unread,
Sep 4, 2009, 4:40:05 AM9/4/09
to Android Developers
Hi Dianne,

this is what I did, and it didn't work:

WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.width = WindowManager.LayoutParams.FILL_PARENT;
lp.height = WindowManager.LayoutParams.FILL_PARENT;
getWindow().setAttributes(lp);

that has no effect whatsoever (I called it in onCreate(), tried
calling it before and after the super.onCreate(), but no luck).

What I do now is implement a custom LinearLayout for the activity
where I override onMeasure() and set the width and height to the
screen width and height. But that's incorrect of course, because that
size is larger than the actual canvas (it doesn't account for menu and
toolbars).

Can you help me out here? Why is there no simple way to fix a dialog's
size?

Cheers,
Matthias

On Sep 1, 6:55 pm, Dianne Hackborn <hack...@android.com> wrote:
> The dialog theme, as part of its nature, sets the top-level window layout to
> be WRAP_CONTENT.  You could try manually setting the Window layout width and
> height to FILL_PARENT, though this is going to make for a kind-of weird
> dialog (especially if one day you find yourself running on a large
> screen...).
>
>
>
> On Tue, Sep 1, 2009 at 7:18 AM, matthias <m.kaepp...@googlemail.com> wrote:
>
> > Hi, I am also trying to find a solution to this...
>
> > On Jul 31, 4:41 pm, "nEx.Software" <email.nex.softw...@gmail.com>
> > wrote:
> > > Just out of curiosity, why are you using a dialog if you want it to
> > > fill the screen?
>
> > simply because there are occasions where you need to replace content
> > in the dialog dynamically and you don't want the dialog to resize but
> > remain at full width and height. For instance, I need to display
> > images of different width and height in the dialog, and I don't want
> > the dialog to change size with every image the user looks at.
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
Reply all
Reply to author
Forward
0 new messages