Android

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,

<activity
android:label="@string/app_name"
android:name=".DialogActivity"
android:theme="@android:style/Theme.Dialog" />
<activity/>

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…

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.your_layout);
    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 http://stackoverflow.com/questions/1362723/how-can-i-get-a-dialog-style-activity-window-to-fill-the-screen/1693716#1693716

Hope it helps somebody.

 

 

Leave a Reply

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