How to make an Alert Dialog in full screen in Android?
            Asked
            
        
        
            Active
            
        
            Viewed 4.1k times
        
    23
            
            
        - 
                    2This is not a way to ask question on StackOverflow. Provide what you have worked on, any tutorial or your code snippet. – Krrishnaaaa Jul 23 '16 at 17:19
4 Answers
29
            
            
        Try below code
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this,android.R.style.Theme_Black_NoTitleBar_Fullscreen);
 
    
    
        emrekose26
        
- 683
- 1
- 8
- 21
17
            
            
        you must create a custom style for your dialog
in your style.xml
 <style name="DialogTheme" parent="android:Theme.Dialog">
    <item name="android:layout_width">fill_parent</item>
    <item name="android:layout_height">fill_parent</item>   
    <!-- No backgrounds, titles or window float -->
    <item name="android:windowBackground">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">false</item>
</style>
while inflating your dialog set this theme
dialog = new Dialog(this, R.style.DialogTheme);
 
    
    
        SaravInfern
        
- 3,338
- 1
- 20
- 44
14
            
            
        【Method 1 | Use Custom Style】
In styles file:
<style name="myFullscreenAlertDialogStyle" parent="Theme.AppCompat.Light.NoActionBar">      //no actionbar, but status bar exists
    <item name="android:windowFullscreen">true</item>                       //remove status bar
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>        //smooth animation
    <item name="colorAccent">@color/colorAccent</item>                      //change button text color
</style>
In java file:
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.myFullscreenAlertDialogStyle);   //second argument
【Method 2 | Use Built-In Style】
In java file:
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), android.R.style.Theme_Material_Light_NoActionBar_Fullscreen);
- This method will make the button text become green color, you can use dialog.getButton().setTextColor()to change it.
 
    
    
        Sam Chen
        
- 7,597
- 2
- 40
- 73
2
            
            
        if you're using DialogFragment to build AlertDialog you may set MATCH_PARENT on LayoutParams in onResume():
@Override
public void onResume() {
    super.onResume();
    ViewGroup.LayoutParams params = getDialog().getWindow().getAttributes();
    params.width = WindowManager.LayoutParams.MATCH_PARENT;
    params.height = WindowManager.LayoutParams.MATCH_PARENT;
    getDialog().getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
}
 
    
    
        madim
        
- 774
- 10
- 22
- 
                    1While this does work, the vie winside it doesn't go with MATCH_PARENT – Marcos Vasconcelos Jan 31 '19 at 18:57
 
    