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:de.grobox.transportr.trips.search.ProductDialogFragment.java

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

    // adjust width and height to be shown properly in landscape orientation
    Dialog dialog = getDialog();/*from ww w. j  a  v  a  2 s  . c  o m*/
    if (dialog != null) {
        Window window = dialog.getWindow();
        if (window != null) {
            int width = ViewGroup.LayoutParams.MATCH_PARENT;
            int height = ViewGroup.LayoutParams.MATCH_PARENT;
            window.setLayout(width, height);
        }
    }
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.jump_to_time, container);
    ((TextView) view.findViewById(R.id.jump_dialog_title)).setText(getTitle());
    mHours = (EditText) view.findViewById(R.id.jump_hours);
    mMinutes = (EditText) view.findViewById(R.id.jump_minutes);
    mSeconds = (EditText) view.findViewById(R.id.jump_seconds);
    mMillis = (EditText) view.findViewById(R.id.jump_millis);
    mActionButton = (Button) view.findViewById(R.id.jump_go);
    mSign = (TextView) view.findViewById(R.id.jump_sign);

    mMinutes.setOnFocusChangeListener(this);
    mSeconds.setOnFocusChangeListener(this);

    mMinutes.setOnEditorActionListener(this);
    mSeconds.setOnEditorActionListener(this);

    mActionButton.setOnClickListener(this);
    mActionButton.setOnFocusChangeListener(this);

    mTextColor = mMinutes.getCurrentTextColor();

    view.findViewById(R.id.jump_minutes_up).setOnClickListener(this);
    view.findViewById(R.id.jump_minutes_down).setOnClickListener(this);
    view.findViewById(R.id.jump_seconds_up).setOnClickListener(this);
    view.findViewById(R.id.jump_seconds_down).setOnClickListener(this);
    if (BuildConfig.tv) {
        mHours.setInputType(InputType.TYPE_NULL);
        mMinutes.setInputType(InputType.TYPE_NULL);
        mSeconds.setInputType(InputType.TYPE_NULL);
        mMillis.setInputType(InputType.TYPE_NULL);
        mHours.setOnClickListener(this);
        mMinutes.setOnClickListener(this);
        mSeconds.setOnClickListener(this);
        mMillis.setOnClickListener(this);
    }//  w w  w  . ja  va2s.  com

    getDialog().setOnKeyListener(this);
    getDialog().setCancelable(true);
    getDialog().setCanceledOnTouchOutside(true);
    Window window = getDialog().getWindow();
    window.setBackgroundDrawableResource(Util.getResourceFromAttribute(getActivity(), R.attr.rounded_bg));
    window.setLayout(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
    return view;
}

From source file:com.ovrhere.android.careerstack.ui.fragments.dialogs.SearchBarDialogFragment.java

@Override
public void onResume() {
    super.onResume();
    //must be done after view is created
    if (getDialog() != null) {
        Window win = getDialog().getWindow();
        win.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        getDialog().setCanceledOnTouchOutside(true);
    }/*from w  w w.  j a  v  a 2s .c o m*/
}

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);/*from   w  ww . ja va 2 s.  c o  m*/

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

    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);/*  w w  w  . j a va 2 s  . c  o m*/

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

    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.github.rutvijkumar.twittfuse.fragments.ComposeDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Dialog dialog = getDialog();/*from w ww . java  2  s.  com*/
    Window window = dialog.getWindow();
    View view = inflater.inflate(R.layout.compose_dialog, container);
    window.requestFeature(Window.FEATURE_NO_TITLE);
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    setUpUI(view);
    getUserAccountDetails();
    return view;
}

From source file:org.catrobat.catroid.ui.dialogs.AddBrickDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.dialog_brick_add, null);

    ImageButton closeButton = (ImageButton) rootView.findViewById(R.id.dialog_brick_title_button_close);
    TextView textView = (TextView) rootView.findViewById(R.id.dialog_brick_title_text_view_title);
    listView = (ListView) rootView.findViewById(R.id.dialog_brick_add_list_view);

    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override//from w w w .j av  a 2s .c  om
        public void onClick(View v) {
            dismiss();
        }
    });

    textView.setText(selectedCategory);

    Window window = getDialog().getWindow();
    window.requestFeature(Window.FEATURE_NO_TITLE);
    window.setGravity(Gravity.CENTER | Gravity.FILL_HORIZONTAL | Gravity.FILL_VERTICAL);
    window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    return rootView;
}

From source file:com.orange.ocara.ui.dialog.AudioPlayerDialog.java

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

    // safety check
    if (getDialog() == null)
        return;//  ww w. ja  v  a2 s.  c  o m

    // set dialog width

    Window window = getDialog().getWindow();

    // set "origin" to top left corner
    window.setGravity(Gravity.TOP); //| Gravity.LEFT);

    int width = getResources().getDimensionPixelSize(R.dimen.audioPlayerDialogWidth);
    window.setLayout(width, WindowManager.LayoutParams.WRAP_CONTENT);

    WindowManager.LayoutParams attributes = window.getAttributes();

    Integer argX = getArguments().getInt("x");
    Integer argY = getArguments().getInt("y");
    if (argX != null && argX >= 0) {
        attributes.x = argX;
    }
    if (argY != null && argY >= 0) {
        attributes.y = argY;
    }

    window.setAttributes(attributes);

}

From source file:com.itude.mobile.mobbl.core.controller.util.MBBasicViewController.java

/**
 * @see android.support.v4.app.DialogFragment#onStart()
 * // w w  w  .ja  v a 2  s.co  m
 * This method is used to do stuff with the AlertDialog created in onCreateDialog based
 * on optional parameters passed to this DialogFragment.
 */
@Override
public void onStart() {
    super.onStart();

    // At this point, Dialog.show is invoked; resolves the issue of first calling requestFeature
    // before doing view stuff. But this is only for the AlertDialog, i.e. closable dialogs
    if (getShowsDialog() && _isDialogClosable) {
        FrameLayout layout = (FrameLayout) getDialog().findViewById(android.R.id.custom);
        if (layout != null)
            layout.setPadding(0, 0, 0, 0);

        styleCloseButton();
    }

    if (getShowsDialog() && _isDialogFullscreen) {
        Window window = getDialog().getWindow();
        window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_advanced_options, container, false);
    getDialog().setCancelable(true);// w ww  . j a v a2 s .  c om
    getDialog().setCanceledOnTouchOutside(true);

    mSeek = (SeekBar) root.findViewById(R.id.playback_speed_seek);
    mSpeedTv = (TextView) root.findViewById(R.id.playback_speed_value);
    mReset = (Button) root.findViewById(R.id.playback_speed_reset);

    mSeek.setOnSeekBarChangeListener(mSeekBarListener);
    mReset.setOnClickListener(mResetListener);

    mSleepTitle = (TextView) root.findViewById(R.id.sleep_timer_title);
    mSleepTime = (TextView) root.findViewById(R.id.sleep_timer_value);
    mSleepCancel = (TextView) root.findViewById(R.id.sleep_timer_cancel);
    mJumpTitle = (TextView) root.findViewById(R.id.jump_title);

    mJumpTitle.setOnClickListener(this);

    if (BuildConfig.tv) {
        root.findViewById(R.id.sleep_timer_container).setVisibility(View.GONE);
    } else {
        mSleepTitle.setOnClickListener(this);
        mSleepTime.setOnClickListener(this);
        mSleepCancel.setOnClickListener(this);
    }

    mReset.setOnFocusChangeListener(mFocusListener);
    mSleepTime.setOnFocusChangeListener(mFocusListener);
    mSleepCancel.setOnFocusChangeListener(mFocusListener);
    mJumpTitle.setOnFocusChangeListener(mFocusListener);

    if (mMode == MODE_VIDEO) {
        mAudioMode = (TextView) root.findViewById(R.id.playback_switch_audio);
        mAudioMode.setOnClickListener(this);
        mAudioMode.setOnFocusChangeListener(mFocusListener);

        mChapters = (Spinner) root.findViewById(R.id.jump_chapter);
        mChaptersTitle = (TextView) root.findViewById(R.id.jump_chapter_title);

        mAudioDelay = (TextView) root.findViewById(R.id.audio_delay);
        mSpuDelay = (TextView) root.findViewById(R.id.spu_delay);

        mSpuDelay.setOnClickListener(this);
        mSpuDelay.setOnFocusChangeListener(mFocusListener);
        mAudioDelay.setOnClickListener(this);
        mAudioDelay.setOnFocusChangeListener(mFocusListener);
        initChapterSpinner();
    } else {
        root.findViewById(R.id.audio_delay).setVisibility(View.GONE);
        root.findViewById(R.id.spu_delay).setVisibility(View.GONE);
        root.findViewById(R.id.jump_chapter).setVisibility(View.GONE);
        root.findViewById(R.id.jump_chapter_title).setVisibility(View.GONE);
        root.findViewById(R.id.playback_switch_audio).setVisibility(View.GONE);

    }

    if (mMode == MODE_AUDIO) {
        mEqualizer = (TextView) root.findViewById(R.id.opt_equalizer);
        mEqualizer.setOnClickListener(this);
        mEqualizer.setOnFocusChangeListener(mFocusListener);
    } else
        root.findViewById(R.id.opt_equalizer).setVisibility(View.GONE);
    mHandler.sendEmptyMessage(TOGGLE_CANCEL);
    mTextColor = mSleepTitle.getCurrentTextColor();
    final MediaPlayer mediaplayer = VLCInstance.getMainMediaPlayer();

    double speed = mediaplayer.getRate();
    if (speed != 1.0d) {
        speed = 100 * (1 + Math.log(speed) / Math.log(4));
        mSeek.setProgress((int) speed);
    }

    Window window = getDialog().getWindow();
    window.setBackgroundDrawableResource(Util.getResourceFromAttribute(getActivity(), R.attr.rounded_bg));
    window.setLayout(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
    return root;
}