Created
April 30, 2016 06:00
-
-
Save marc0x71/f571f4dfe328b662860cd4e80bd7f6af to your computer and use it in GitHub Desktop.
Set the width of the DialogFragment proportional to 90% of the screen width
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onResume() { | |
// Set the width of the dialog proportional to 90% of the screen width | |
Window window = getDialog().getWindow(); | |
Point size = new Point(); | |
Display display = window.getWindowManager().getDefaultDisplay(); | |
display.getSize(size); | |
window.setLayout((int) (size.x * 0.90), WindowManager.LayoutParams.WRAP_CONTENT); | |
window.setGravity(Gravity.CENTER); | |
super.onResume(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!