Example usage for android.view Window setAttributes

List of usage examples for android.view Window setAttributes

Introduction

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

Prototype

public void setAttributes(WindowManager.LayoutParams a) 

Source Link

Document

Specify custom window attributes.

Usage

From source file:com.kccomy.orgar.ui.note.NoteFragment.java

private void setWindowAlpha(float f) {
    Window window = getActivity().getWindow();
    WindowManager.LayoutParams lp = window.getAttributes();
    lp.alpha = f;/*from  ww w.  ja va 2 s .  com*/
    window.setAttributes(lp);
}

From source file:com.daxstudio.sa.base.android.BaseDialogFragment.java

@Override
public void onStart() {
    super.onStart();
    // Less dimmed background; see http://stackoverflow.com/q/13822842/56285
    final Window window = getDialog().getWindow();
    final WindowManager.LayoutParams params = window.getAttributes();
    params.dimAmount = getDimAmount(); // dim only a little bit
    window.setAttributes(params);

    window.setLayout(getWidth(), getHeight());
    window.setGravity(getGravity());// w  w w .  j  ava 2  s .  c om

    // Transparent background; see http://stackoverflow.com/q/15007272/56285
    // (Needed to make dialog's alpha shadow look good)
    window.setBackgroundDrawableResource(android.R.color.transparent);

    final Resources res = getResources();
    final int titleDividerId = res.getIdentifier("titleDivider", "id", "android");
    if (titleDividerId > 0) {
        final View titleDivider = getDialog().findViewById(titleDividerId);
        if (titleDivider != null) {
            titleDivider.setBackgroundColor(res.getColor(android.R.color.transparent));
        }
    }
}

From source file:com.github.piasy.bootstrap.base.android.BaseDialogFragment.java

@Override
public void onStart() {
    super.onStart();
    // Less dimmed background; see http://stackoverflow.com/q/13822842/56285
    final Window window = getDialog().getWindow();
    if (window != null) {
        final WindowManager.LayoutParams params = window.getAttributes();
        params.dimAmount = getDimAmount(); // dim only a little bit
        window.setAttributes(params);

        window.setLayout(getWidth(), getHeight());
        window.setGravity(getGravity());

        // Transparent background; see http://stackoverflow.com/q/15007272/56285
        // (Needed to make dialog's alpha shadow look good)
        window.setBackgroundDrawableResource(android.R.color.transparent);
    }//from w w w.j ava 2s .  co m

    final Resources res = getResources();
    final int titleDividerId = res.getIdentifier("titleDivider", "id", "android");
    if (titleDividerId > 0) {
        final View titleDivider = getDialog().findViewById(titleDividerId);
        if (titleDivider != null) {
            titleDivider.setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent));
        }
    }
}

From source file:com.timothy.android.api.fragment.PageFragment.java

public void openDialog(String content) {
    //      Log.i(LOG_TAG, "openDialog()...");
    CustomDialog cusDialog = new CustomDialog(activity, R.style.custom_dialog_style, content);
    Window wd = cusDialog.getWindow();
    WindowManager.LayoutParams lp = wd.getAttributes();
    lp.alpha = 1.0f;// w w w  .  j  av a 2s. c  o  m
    wd.setAttributes(lp);
    cusDialog.show();
}

From source file:com.hellofyc.base.app.AppSupportDelegate.java

private void setAttributesFlag(int flags, boolean trueOrFalse) {
    Window win = mActivity.getWindow();
    LayoutParams params = win.getAttributes();
    if (trueOrFalse) {
        params.flags |= flags;// www. ja v  a  2  s . c  om
    } else {
        params.flags &= ~flags;
    }
    win.setAttributes(params);
}

From source file:com.timothy.android.api.fragment.PageFragmentNew.java

public void openDialog(String content) {
    CustomDialog cusDialog = new CustomDialog(activity, R.style.custom_dialog_style, content);
    Window wd = cusDialog.getWindow();
    WindowManager.LayoutParams lp = wd.getAttributes();
    lp.alpha = 1.0f;//from w  w  w . java 2 s.c om
    wd.setAttributes(lp);
    cusDialog.show();
}

From source file:com.qiangxi.checkupdatelibrary.dialog.CheckUpdateDialog.java

private void resizeWidthAndHeight() {
    Window window = getWindow();
    if (window == null)
        return;//from   ww  w. ja  va2s .c o m
    WindowManager.LayoutParams lp = window.getAttributes();
    lp.gravity = Gravity.CENTER;
    lp.width = dp2px(260);//260dp
    lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
    window.setAttributes(lp);
}

From source file:com.king.base.BaseActivity.java

private void setDialogWindow(Dialog dialog, float widthRatio) {
    Window window = dialog.getWindow();
    WindowManager.LayoutParams lp = window.getAttributes();
    int width = Math.min(getWidthPixels(), getHeightPixels());
    lp.width = (int) (width * widthRatio);
    window.setAttributes(lp);
}

From source file:com.example.deii.Fragments.UpdateProfileFragment.java

private void showPicSelectDialog(final Context ctx) {

    dialog = new Dialog(ctx, R.style.DialogSlideAnim1);
    dialog.setContentView(R.layout.dialog_select_image);
    dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
    Window window = dialog.getWindow();
    WindowManager.LayoutParams wlp = window.getAttributes();
    wlp.gravity = Gravity.BOTTOM;/*ww w  . ja v  a2 s  . c  om*/
    wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
    window.setAttributes(wlp);

    TextView chooseFromGallery = (TextView) dialog.findViewById(R.id.text_fromGallery);
    chooseFromGallery.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                loadPermissions(Manifest.permission.READ_EXTERNAL_STORAGE, GALLERY_REQUEST);
            } else
                startGallery();
        }
    });

    TextView takeFromCamera = (TextView) dialog.findViewById(R.id.text_fromCamera);
    takeFromCamera.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
                loadPermissions(Manifest.permission.CAMERA, CAMERA_REQUEST);
            else
                startCamera();
        }
    });

    TextView imgCancel = (TextView) dialog.findViewById(R.id.text_dialogClose);
    imgCancel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    dialog.show();
}

From source file:com.hacktx.android.activities.CheckInActivity.java

private void setTranslucentStatusFlag(boolean on) {
    if (Build.VERSION.SDK_INT >= 19) {
        Window win = getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if (on) {
            winParams.flags |= bits;/*from   w  w  w .j a v  a 2s .co m*/
        } else {
            winParams.flags &= ~bits;
        }
        win.setAttributes(winParams);
    }
}