Skip to content

Instantly share code, notes, and snippets.

@tatuas
Last active January 1, 2016 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tatuas/8069705 to your computer and use it in GitHub Desktop.
Save tatuas/8069705 to your computer and use it in GitHub Desktop.
DialogFragmentでダイアログサイズを変更する
@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