Example usage for android.view Window setBackgroundDrawableResource

List of usage examples for android.view Window setBackgroundDrawableResource

Introduction

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

Prototype

public void setBackgroundDrawableResource(@DrawableRes int resId) 

Source Link

Document

Change the background of this window to a Drawable resource.

Usage

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  ww .  ja v  a2  s.  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.InputDialogFragment.java

@Override
public void onStart() {
    super.onStart();
    Window window = getDialog().getWindow();
    window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    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 w w  w . j a  va2 s . co  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);/*from  w w  w .j av  a 2 s .  com*/
    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.jun.elephant.ui.widget.VoteDialog.java

private void initContentView() {
    View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_vote, null);

    Rect displayRectangle = new Rect();
    Window window = getWindow();
    window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle);
    view.setMinimumWidth((int) (displayRectangle.width() * 0.8f));
    window.setBackgroundDrawableResource(R.color.dialog_bg);

    setContentView(view);//from  w w  w.j  av  a2 s.com
}

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. jav  a 2 s  .c  o m

    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.miz.utils.ViewUtils.java

public static void setupWindowFlagsForStatusbarOverlay(Window window, boolean setBackgroundResource) {

    if (MizLib.isKitKat()) {
        // If we're running on KitKat, we want to enable
        // the translucent status bar
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }//w  w w.j av a  2  s.  c  o m

    if (MizLib.hasKitKat()) {
        // If we're running on KitKat or above, we want to show
        // the background image beneath the status bar as well.
        window.getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    }

    // Make the status bar color transparent to begin with
    if (MizLib.hasLollipop())
        window.setStatusBarColor(Color.TRANSPARENT);

    // If requested, set a background resource on the Window object
    if (setBackgroundResource)
        window.setBackgroundDrawableResource(R.drawable.bg);
}

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

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;//from   www.j a v  a  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.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);/*  w w  w .ja v  a  2s . 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  ww  .j a va2 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));
        }
    }
}