Example usage for android.view Window setLayout

List of usage examples for android.view Window setLayout

Introduction

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

Prototype

public void setLayout(int width, int height) 

Source Link

Document

Set the width and height layout parameters of the window.

Usage

From source file:com.tdispatch.passenger.core.TDDialogFragment.java

@Override
public void onResume() {

    Window w = getDialog().getWindow();

    // Auto size the dialog based on it's contents
    w.setLayout(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    //w.setBackgroundDrawableResource(resid)

    // Disable standard dialog styling/frame/theme: our custom view should create full UI
    //      setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme);

    super.onResume();
}

From source file:com.pyamsoft.dontsuckmp.album.AlbumDialog.java

@Override
public void onResume() {
    super.onResume();
    // The dialog is super small for some reason. We have to set the size manually, in onResume
    final Window window = getDialog().getWindow();
    if (window != null) {
        window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
    }/* w  w  w.java  2s .c o  m*/
}

From source file:org.videolan.vlc.gui.dialogs.SelectChapterDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.dialog_select_chapter, container);
    mChapterList = (ListView) view.findViewById(R.id.chapter_list);

    getDialog().setCancelable(true);//w  w  w .java2s  .  c  om
    getDialog().setCanceledOnTouchOutside(true);
    Window window = getDialog().getWindow();
    window.setBackgroundDrawableResource(UiTools.getResourceFromAttribute(getActivity(), R.attr.rounded_bg));
    window.setLayout(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
    return view;
}

From source file:com.xiangqin.app.dialog.AbSampleDialogFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    Window window = getDialog().getWindow();
    WindowManager.LayoutParams attributes = window.getAttributes();
    attributes.gravity = mGravity;//from   www .ja  va 2s.co m
    window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    window.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#88818181")));
    super.onActivityCreated(savedInstanceState);
}

From source file:com.jalotsav.aalayamnavjivan.ActvtyBookView.java

private void getBookFromFirebaseStorage() {

    mDialogPrgrs = new Dialog(this);
    mDialogPrgrs.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mDialogPrgrs.setContentView(R.layout.lo_dialog_progress);
    Window window = mDialogPrgrs.getWindow();
    window.setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    mDialogPrgrs.show();//w  w w.  j  ava 2 s .  c  o m

    TextView tvDialogMessage = mDialogPrgrs.findViewById(R.id.tv_dialog_progress_message);
    final TextView tvDialogPrcntg = mDialogPrgrs.findViewById(R.id.tv_dialog_progress_prcntg);
    tvDialogMessage.setText(mWaitGettingBook);
    tvDialogPrcntg.setText(String.format(Locale.getDefault(), "%1$d%%", 0));

    File bookFilePathLocal = new File(AppConstants.PATH_BOOKS_NAVJIVAN);
    bookFilePathLocal.mkdirs();
    File bookFilePathLocalName = new File(bookFilePathLocal, mRequestedBookName);
    if (bookFilePathLocalName.exists())
        bookFilePathLocalName.delete();

    StorageReference booksNavjivanRef = mStorageRef
            .child(AppConstants.PATH_FIRESTORAGE_BOOK_NAVJIVAN + mRequestedBookName);
    booksNavjivanRef.getFile(bookFilePathLocalName)
            .addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
                @Override
                public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {

                    mDialogPrgrs.dismiss();
                    getBookFromLocalStorage();
                }
            }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception exception) {

                    mDialogPrgrs.dismiss();
                    Snackbar.make(mCrdntrlyot, mServerPrblmMsg, Snackbar.LENGTH_LONG).show();
                }
            }).addOnProgressListener(new OnProgressListener<FileDownloadTask.TaskSnapshot>() {
                @Override
                public void onProgress(FileDownloadTask.TaskSnapshot taskSnapshot) {

                    double progress = (100.0 * taskSnapshot.getBytesTransferred())
                            / taskSnapshot.getTotalByteCount();
                    tvDialogPrcntg.setText(String.format(Locale.getDefault(), "%1$d%%", (int) progress));
                }
            });
}

From source file:com.ofalvai.bpinfo.ui.alert.AlertDetailFragment.java

@Override
public void onStart() {
    super.onStart();

    // Bottom sheets on tablets should have a smaller width than the screen width.
    int width = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_width);
    int actualWidth = width > 0 ? width : ViewGroup.LayoutParams.MATCH_PARENT;
    Window window = getDialog().getWindow();
    if (window != null) {
        window.setLayout(actualWidth, ViewGroup.LayoutParams.MATCH_PARENT);
    }/*from w  ww.ja  va  2 s.  c  o  m*/
}

From source file:org.videolan.vlc.gui.dialogs.PlaybackSpeedDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.dialog_playback_speed, container);
    mSpeedValue = (TextView) view.findViewById(R.id.playback_speed_value);
    mSeekSpeed = (SeekBar) view.findViewById(R.id.playback_speed_seek);
    mPlaybackSpeedIcon = (ImageView) view.findViewById(R.id.playback_speed_icon);
    mPlaybackSpeedPlus = (ImageView) view.findViewById(R.id.playback_speed_plus);
    mPlaybackSpeedMinus = (ImageView) view.findViewById(R.id.playback_speed_minus);

    mSeekSpeed.setOnSeekBarChangeListener(mSeekBarListener);
    mPlaybackSpeedIcon.setOnClickListener(mResetListener);
    mPlaybackSpeedPlus.setOnClickListener(mSpeedUpListener);
    mPlaybackSpeedMinus.setOnClickListener(mSpeedDownListener);
    mSpeedValue.setOnClickListener(mResetListener);
    mPlaybackSpeedMinus.setOnTouchListener(new OnRepeatListener(mSpeedDownListener));
    mPlaybackSpeedPlus.setOnTouchListener(new OnRepeatListener(mSpeedUpListener));

    mTextColor = mSpeedValue.getCurrentTextColor();

    getDialog().setCancelable(true);//w ww  . j  a  va 2s.  c  o  m
    getDialog().setCanceledOnTouchOutside(true);
    Window window = getDialog().getWindow();
    window.setBackgroundDrawableResource(UiTools.getResourceFromAttribute(getActivity(), R.attr.rounded_bg));
    window.setLayout(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
    return view;
}

From source file:com.github.piasy.chatrecyclerview.example.InputDialog.java

@Override
public void onStart() {
    super.onStart();
    // without title and title divider

    // Less dimmed background; see http://stackoverflow.com/q/13822842/56285
    Window window = getDialog().getWindow();
    WindowManager.LayoutParams params = window.getAttributes();
    //CHECKSTYLE:OFF
    params.dimAmount = 0;/* w w w . j  a  va  2  s . c  o m*/
    //CHECKSTYLE:ON
    window.setAttributes(params);

    window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    window.setGravity(Gravity.BOTTOM);

    // 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.robopupu.api.mvp.ViewCompatDialogFragment.java

protected void setupWindowLayout(final Window window) {
    window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
}

From source file:com.sbgapps.scoreit.numberpicker.NumberPickerDialogFragment.java

@Override
public void onResume() {
    super.onResume();
    Window window = getDialog().getWindow();
    DisplayMetrics dm = getResources().getDisplayMetrics();
    int width = Math.min(getActivity().getResources().getDimensionPixelSize(R.dimen.dialog_width),
            dm.widthPixels * 3 / 4);//from  w  w w. ja  v a 2  s .  c om
    int height = window.getAttributes().height;
    window.setLayout(width, height);
}