Example usage for android.view Window peekDecorView

List of usage examples for android.view Window peekDecorView

Introduction

In this page you can find the example usage for android.view Window peekDecorView.

Prototype

public abstract View peekDecorView();

Source Link

Document

Retrieve the current decor view, but only if it has already been created; otherwise returns null.

Usage

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();
}