Android Addicted Apps Creator

September 11, 2012

Make Activity using Theme.Dialog fill the entire screen

Filed under: Tips — alin b. @ 07:55
Tags: , , ,

   Admitted, you hate using AlertDialog for complex layouts that contain many controls. I hate it, it makes me feel so limited. Of course it has its own advantages, let’s not be mean, but sometimes a new Activity unleashes the power within.

So, how do we make an Activity look like a dialog ? Simple, just add in manifest:

             android:theme="@android:style/Theme.Dialog" />

    But the problem is, even if we set our layout properties, to fill_screen, the activity will wrap around the content and its size will vary of the info. I thought, if the xml setting is ignored, maybe setting it in code might work… and surprise, it does work. All you have to do is:

public void onCreate(Bundle savedInstanceState) {


    //after setContentView, set the Layout parameters to fill parent, this makes our activity to go full screen
    getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: