Last active
January 1, 2016 00:59
-
-
Save tatuas/8069705 to your computer and use it in GitHub Desktop.
DialogFragmentでダイアログサイズを変更する
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 onActivityCreated(Bundle savedInstanceState) { | |
super.onActivityCreated(savedInstanceState); | |
Dialog dialog = getDialog(); | |
WindowManager.LayoutParams lp = dialog.getWindow().getAttributes(); | |
DisplayMetrics metrics = getResources().getDisplayMetrics(); | |
// 画面サイズの0.8倍の大きさに指定 | |
int dialogWidth = (int) (metrics.widthPixels * 0.8); | |
int dialogHeight = (int) (metrics.heightPixels * 0.8); | |
lp.width = dialogWidth; | |
lp.height = dialogHeight; | |
dialog.getWindow().setAttributes(lp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment