Guest User

Untitled

a guest
Jan 9th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. //show the dialog first
  2. AlertDialog dialog = new AlertDialog.Builder(this)
  3. .setTitle("Test Dialog")
  4. .setMessage("This should expand to the full width")
  5. .show();
  6. //Grab the window of the dialog, and change the width
  7. WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
  8. Window window = dialog.getWindow();
  9. lp.copyFrom(window.getAttributes());
  10. //This makes the dialog take up the full width
  11. lp.width = WindowManager.LayoutParams.MATCH_PARENT;
  12. lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
  13. window.setAttributes(lp);
  14.  
  15. import android.support.v7.app.AlertDialog;
  16.  
  17. import android.app.AlertDialog;
Add Comment
Please, Sign In to add comment