List of usage examples for android.view Window peekDecorView
public abstract View peekDecorView();
From source file:com.pdftron.pdf.controls.PrintAnnotationsSummaryDialogFragment.java
@Override public void onStart() { super.onStart(); mDialogButton = mDialog.getButton(AlertDialog.BUTTON_POSITIVE); if (Utils.isTablet(getActivity())) { // a hack for shrinking the dialog's width final int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); Window window = mDialog.getWindow(); View view = window.peekDecorView(); if (view != null && Utils.isHoneycombMR2()) { view.measure(spec, spec);//w w w . ja v a2s . c o m int width = 3 * view.getMeasuredWidth() / 2; Display display = getActivity().getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int widthScreen = size.x; if (width < 2 * widthScreen / 3) { mDialog.getWindow().setLayout(width, LinearLayout.LayoutParams.WRAP_CONTENT); } } } updateWidgets(); }