Created
June 30, 2014 06:13
-
-
Save douzifly/148975a2feed13904b2f to your computer and use it in GitHub Desktop.
dialog width match parent
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
void show() { | |
final Dialog dialog = new Dialog(this); | |
final Window window = dialog.getWindow(); | |
window.requestFeature(Window.FEATURE_NO_TITLE); | |
window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); | |
// set content view must before set other attributes | |
dialog.setContentView(R.layout.dialog_content); | |
final WindowManager.LayoutParams lp = window.getAttributes(); | |
lp.width = WindowManager.LayoutParams.MATCH_PARENT; | |
lp.height = WindowManager.LayoutParams.WRAP_CONTENT; | |
lp.dimAmount = 0.3f; | |
lp.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND; | |
lp.softInputMode |= WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; | |
lp.gravity = Gravity.BOTTOM; | |
window.setAttributes(lp); | |
dialog.getWindow().setBackgroundDrawable(null); | |
dialog.show(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment