Get a Dialog style activity window to fill the screen-Android

Applying Dialog Style to Activity

Generally when we set Activity theme as dialog style,

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

its just display at the center of the screen, with specific width and height set in the XML Layout file or as per the Content. as shown below.

Dialog style

At times you may want to display Dialog activity as Full screen like a Child screen over a Parent screen. To do that, here is snippet code…

public void onCreate(Bundle savedInstanceState) {
    getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

here Important point is, you should place the getWindow().setLayout() method statement after setContentView() method, otherwise it won’t work.

Ref link

Hope it helps somebody.

Leave a Reply

Your email address will not be published. Required fields are marked *