Example usage for android.graphics.drawable ColorDrawable ColorDrawable

List of usage examples for android.graphics.drawable ColorDrawable ColorDrawable

Introduction

In this page you can find the example usage for android.graphics.drawable ColorDrawable ColorDrawable.

Prototype

public ColorDrawable() 

Source Link

Document

Creates a new black ColorDrawable.

Usage

From source file:Main.java

private static Drawable createPlaceholder(Drawable original) {
    Drawable placeholder = new ColorDrawable();
    placeholder.setBounds(original.getBounds());
    return placeholder;
}

From source file:com.facebook.litho.testing.TestDrawableComponent.java

@Override
protected Object onCreateMountContent(ComponentContext c) {
    return new ColorDrawable();
}

From source file:android.support.v17.leanback.app.DetailsSupportFragmentBackgroundController.java

/**
 * Enables default parallax background using a {@link FitWidthBitmapDrawable} as cover drawable
 * and {@link ColorDrawable} as bottom drawable. A vertical parallax movement will be applied
 * to the FitWidthBitmapDrawable. App may use {@link #setSolidColor(int)} and
 * {@link #setCoverBitmap(Bitmap)} to change the content of bottom drawable and cover drawable.
 * This method must be called before {@link #setupVideoPlayback(PlaybackGlue)}.
 *
 * @see #setCoverBitmap(Bitmap)//from  w  w w .j a  v a2  s  . c  om
 * @see #setSolidColor(int)
 * @throws IllegalStateException If {@link #setupVideoPlayback(PlaybackGlue)} was called.
 */
public void enableParallax() {
    int offset = mParallaxDrawableMaxOffset;
    if (offset == 0) {
        offset = mFragment.getContext().getResources()
                .getDimensionPixelSize(R.dimen.lb_details_cover_drawable_parallax_movement);
    }
    Drawable coverDrawable = new FitWidthBitmapDrawable();
    ColorDrawable colorDrawable = new ColorDrawable();
    enableParallax(coverDrawable, colorDrawable, new ParallaxTarget.PropertyValuesHolderTarget(coverDrawable,
            PropertyValuesHolder.ofInt(FitWidthBitmapDrawable.PROPERTY_VERTICAL_OFFSET, 0, -offset)));
}

From source file:com.android.launcher3.BubbleTextView.java

/**
 * Used for measurement only, sets some dummy values on this view.
 *//*from  ww w  . j a v a 2s .  c  om*/
public void applyDummyInfo() {
    ColorDrawable d = new ColorDrawable();
    setIcon(mLauncher.resizeIconDrawable(d));
    setText("");
}

From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java

public void updateActionBar() {
    final ActionBar actionBar = getActionBar();

    actionBar.setDisplayShowHomeEnabled(true);

    final boolean showIndicator = !mShowAsDialog && (mState.action != ACTION_MANAGE);
    actionBar.setDisplayHomeAsUpEnabled(showIndicator);
    if (mDrawerToggle != null) {
        mDrawerToggle.setDrawerIndicatorEnabled(showIndicator);
    }/*  w w w . j a v  a  2s  . c  o  m*/

    if (isRootsDrawerOpen()) {
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
        actionBar.setIcon(new ColorDrawable());

        if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) {
            actionBar.setTitle(R.string.title_open);
        } else if (mState.action == ACTION_CREATE) {
            actionBar.setTitle(R.string.title_save);
        }
    } else {
        final RootInfo root = getCurrentRoot();
        actionBar.setIcon(root != null ? root.loadIcon(this) : null);

        if (mState.stack.size() <= 1) {
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
            actionBar.setTitle(root.title);
        } else {
            mIgnoreNextNavigation = true;
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
            actionBar.setTitle(null);
            actionBar.setListNavigationCallbacks(mStackAdapter, mStackListener);
            actionBar.setSelectedNavigationItem(mStackAdapter.getCount() - 1);
        }
    }
}

From source file:com.android.tv.settings.dialog.DialogFragment.java

private void performEntryTransition() {
    final View dialogView = getView();
    final View contentView = (View) dialogView.getTag(R.id.content_fragment);
    final View actionContainerView = dialogView.findViewById(R.id.action_fragment);

    mIntroAnimationInProgress = true;/*from   w ww  .  ja  v a  2s  .co m*/

    // Fade out the old activity.
    getActivity().overridePendingTransition(0, R.anim.lb_dialog_fade_out);

    int bgColor = contentView.getContext().getResources().getColor(R.color.lb_dialog_activity_background);
    final ColorDrawable bgDrawable = new ColorDrawable();
    bgDrawable.setColor(bgColor);
    bgDrawable.setAlpha(0);
    dialogView.setBackground(bgDrawable);
    dialogView.setVisibility(View.INVISIBLE);

    runDelayedAnim(new Runnable() {
        @Override
        public void run() {
            if (!isAdded()) {
                // We have been detached before this could run,
                // so just bail
                return;
            }

            dialogView.setVisibility(View.VISIBLE);

            // Fade in the activity background protection
            ObjectAnimator oa = ObjectAnimator.ofInt(bgDrawable, "alpha", 255);
            oa.setDuration(ANIMATE_IN_DURATION);
            oa.setStartDelay(SECONDARY_ANIMATE_DELAY);
            oa.setInterpolator(new DecelerateInterpolator(1.0f));
            oa.start();

            boolean isRtl = ViewCompat.getLayoutDirection(contentView) == View.LAYOUT_DIRECTION_RTL;
            int startDist = isRtl ? SLIDE_IN_DISTANCE : -SLIDE_IN_DISTANCE;
            int endDist = isRtl ? -actionContainerView.getMeasuredWidth()
                    : actionContainerView.getMeasuredWidth();

            // Fade in and slide in the ContentFragment
            // TextViews from the start.
            prepareAndAnimateView((View) contentView.getTag(R.id.title), startDist, false);
            prepareAndAnimateView((View) contentView.getTag(R.id.breadcrumb), startDist, false);
            prepareAndAnimateView((View) contentView.getTag(R.id.description), startDist, false);

            // Fade in and slide in the ActionFragment from the
            // end.
            prepareAndAnimateView(actionContainerView, endDist, false);
            prepareAndAnimateView((View) contentView.getTag(R.id.icon), startDist, true);

            // Fade in the selector.
            if (mSelectorAnimator != null) {
                mSelectorAnimator.fadeIn();
            }
        }
    });
}

From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java

private void performEntryTransition() {
    final View dialogView = getView();
    final View contentView = (View) dialogView.getTag(R.id.content_fragment);
    final View actionContainerView = dialogView.findViewById(R.id.action_fragment);

    mIntroAnimationInProgress = true;// w  ww . j  av a2s .c  om

    // Fade out the old activity.
    getActivity().overridePendingTransition(0, R.anim.lb_dialog_fade_out);

    int bgColor = contentView.getContext().getResources().getColor(R.color.lb_dialog_activity_background);
    final ColorDrawable bgDrawable = new ColorDrawable();
    bgDrawable.setColor(bgColor);
    bgDrawable.setAlpha(0);
    dialogView.setBackground(bgDrawable);
    dialogView.setVisibility(View.INVISIBLE);

    // We need to defer the remainder of the animation preparation until the first layout has
    // occurred, as we don't yet know the final location of the icon.
    contentView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            contentView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            // if we buildLayer() at this time, the texture is
            // actually not created delay a little so we can make
            // sure all hardware layer is created before animation,
            // in that way we can avoid the jittering of start
            // animation
            contentView.postOnAnimationDelayed(mEntryAnimationRunnable, mAnimateDelay);
        }

        Runnable mEntryAnimationRunnable = new Runnable() {
            @Override
            public void run() {
                if (!isAdded()) {
                    // We have been detached before this could run, so just bail.
                    return;
                }

                dialogView.setVisibility(View.VISIBLE);

                // Fade in the activity background protection
                ObjectAnimator oa = ObjectAnimator.ofInt(bgDrawable, "alpha", 255);
                oa.setDuration(mAnimateInDuration);
                oa.setStartDelay(mSecondaryAnimateDelay);
                oa.setInterpolator(new DecelerateInterpolator(1.0f));
                oa.start();

                boolean isRtl = ViewCompat.getLayoutDirection(contentView) == View.LAYOUT_DIRECTION_RTL;
                int startDist = isRtl ? mSlideInDistance : -mSlideInDistance;
                int endDist = isRtl ? -actionContainerView.getMeasuredWidth()
                        : actionContainerView.getMeasuredWidth();

                // Fade in and slide in the ContentFragment TextViews from the start.
                prepareAndAnimateView((View) contentView.getTag(R.id.title), startDist, false);
                prepareAndAnimateView((View) contentView.getTag(R.id.breadcrumb), startDist, false);
                prepareAndAnimateView((View) contentView.getTag(R.id.description), startDist, false);

                // Fade in and slide in the ActionFragment from the end.
                prepareAndAnimateView(actionContainerView, endDist, false);
                prepareAndAnimateView((View) contentView.getTag(R.id.icon), startDist, true);
            }
        };
    });
}

From source file:com.cpic.taylor.logistics.activity.HomeActivity.java

/**
 * /*w  w  w.j a v a  2s . com*/
 * @param v
 * @param type1
 * @param type2
 * @param isUser
 */
private void showPopupWindow(View v, final int type1, final int type2, final boolean isUser) {
    View view = View.inflate(HomeActivity.this, R.layout.popupwindow_1, null);
    tvCamera = (TextView) view.findViewById(R.id.btn_camera);
    tvPhoto = (TextView) view.findViewById(R.id.btn_photo);
    tvBack = (TextView) view.findViewById(R.id.btn_back);
    tvCamera.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getFromCamera(type1, isUser);
            pw.dismiss();
        }
    });

    tvPhoto.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getFromPhoto(type2);
            pw.dismiss();
        }
    });
    tvBack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            pw.dismiss();
        }
    });

    pw = new PopupWindow(view, screenWidth * 99 / 100, LinearLayout.LayoutParams.WRAP_CONTENT);
    pw.setFocusable(true);
    WindowManager.LayoutParams params = HomeActivity.this.getWindow().getAttributes();
    HomeActivity.this.getWindow().setAttributes(params);

    pw.setBackgroundDrawable(new ColorDrawable());
    pw.setOutsideTouchable(true);

    pw.setAnimationStyle(R.style.pw_anim_style);

    pw.showAtLocation(v, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);

    pw.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            WindowManager.LayoutParams params = HomeActivity.this.getWindow().getAttributes();
            params.alpha = 1f;
            HomeActivity.this.getWindow().setAttributes(params);
        }
    });

}

From source file:android.support.design.widget.TextInputLayout.java

private void updatePasswordToggleView() {
    if (mEditText == null) {
        // If there is no EditText, there is nothing to update
        return;//from   ww w.  j a  v a2 s  .  c o m
    }

    if (shouldShowPasswordIcon()) {
        if (mPasswordToggleView == null) {
            mPasswordToggleView = (CheckableImageButton) LayoutInflater.from(getContext())
                    .inflate(R.layout.design_text_input_password_icon, mInputFrame, false);
            mPasswordToggleView.setImageDrawable(mPasswordToggleDrawable);
            mPasswordToggleView.setContentDescription(mPasswordToggleContentDesc);
            mInputFrame.addView(mPasswordToggleView);

            mPasswordToggleView.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View view) {
                    passwordVisibilityToggleRequested();
                }
            });
        }

        if (mEditText != null && ViewCompat.getMinimumHeight(mEditText) <= 0) {
            // We should make sure that the EditText has the same min-height as the password
            // toggle view. This ensure focus works properly, and there is no visual jump
            // if the password toggle is enabled/disabled.
            mEditText.setMinimumHeight(ViewCompat.getMinimumHeight(mPasswordToggleView));
        }

        mPasswordToggleView.setVisibility(VISIBLE);
        mPasswordToggleView.setChecked(mPasswordToggledVisible);

        // We need to add a dummy drawable as the end compound drawable so that the text is
        // indented and doesn't display below the toggle view
        if (mPasswordToggleDummyDrawable == null) {
            mPasswordToggleDummyDrawable = new ColorDrawable();
        }
        mPasswordToggleDummyDrawable.setBounds(0, 0, mPasswordToggleView.getMeasuredWidth(), 1);

        final Drawable[] compounds = TextViewCompat.getCompoundDrawablesRelative(mEditText);
        // Store the user defined end compound drawable so that we can restore it later
        if (compounds[2] != mPasswordToggleDummyDrawable) {
            mOriginalEditTextEndDrawable = compounds[2];
        }
        TextViewCompat.setCompoundDrawablesRelative(mEditText, compounds[0], compounds[1],
                mPasswordToggleDummyDrawable, compounds[3]);

        // Copy over the EditText's padding so that we match
        mPasswordToggleView.setPadding(mEditText.getPaddingLeft(), mEditText.getPaddingTop(),
                mEditText.getPaddingRight(), mEditText.getPaddingBottom());
    } else {
        if (mPasswordToggleView != null && mPasswordToggleView.getVisibility() == VISIBLE) {
            mPasswordToggleView.setVisibility(View.GONE);
        }

        if (mPasswordToggleDummyDrawable != null) {
            // Make sure that we remove the dummy end compound drawable if it exists, and then
            // clear it
            final Drawable[] compounds = TextViewCompat.getCompoundDrawablesRelative(mEditText);
            if (compounds[2] == mPasswordToggleDummyDrawable) {
                TextViewCompat.setCompoundDrawablesRelative(mEditText, compounds[0], compounds[1],
                        mOriginalEditTextEndDrawable, compounds[3]);
                mPasswordToggleDummyDrawable = null;
            }
        }
    }
}

From source file:com.commonsware.cwac.crossport.design.widget.TextInputLayout.java

private void updatePasswordToggleView() {
    if (mEditText == null) {
        // If there is no EditText, there is nothing to update
        return;/*from ww  w . j a v  a  2s.co  m*/
    }

    if (shouldShowPasswordIcon()) {
        if (mPasswordToggleView == null) {
            mPasswordToggleView = (CheckableImageButton) LayoutInflater.from(getContext())
                    .inflate(R.layout.design_text_input_password_icon, mInputFrame, false);
            mPasswordToggleView.setImageDrawable(mPasswordToggleDrawable);
            mPasswordToggleView.setContentDescription(mPasswordToggleContentDesc);
            mInputFrame.addView(mPasswordToggleView);

            mPasswordToggleView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    passwordVisibilityToggleRequested(false);
                }
            });
        }

        if (mEditText != null && ViewCompat.getMinimumHeight(mEditText) <= 0) {
            // We should make sure that the EditText has the same min-height as the password
            // toggle view. This ensure focus works properly, and there is no visual jump
            // if the password toggle is enabled/disabled.
            mEditText.setMinimumHeight(ViewCompat.getMinimumHeight(mPasswordToggleView));
        }

        mPasswordToggleView.setVisibility(VISIBLE);
        mPasswordToggleView.setChecked(mPasswordToggledVisible);

        // We need to add a dummy drawable as the end compound drawable so that the text is
        // indented and doesn't display below the toggle view
        if (mPasswordToggleDummyDrawable == null) {
            mPasswordToggleDummyDrawable = new ColorDrawable();
        }
        mPasswordToggleDummyDrawable.setBounds(0, 0, mPasswordToggleView.getMeasuredWidth(), 1);

        final Drawable[] compounds = TextViewCompat.getCompoundDrawablesRelative(mEditText);
        // Store the user defined end compound drawable so that we can restore it later
        if (compounds[2] != mPasswordToggleDummyDrawable) {
            mOriginalEditTextEndDrawable = compounds[2];
        }
        TextViewCompat.setCompoundDrawablesRelative(mEditText, compounds[0], compounds[1],
                mPasswordToggleDummyDrawable, compounds[3]);

        // Copy over the EditText's padding so that we match
        mPasswordToggleView.setPadding(mEditText.getPaddingLeft(), mEditText.getPaddingTop(),
                mEditText.getPaddingRight(), mEditText.getPaddingBottom());
    } else {
        if (mPasswordToggleView != null && mPasswordToggleView.getVisibility() == VISIBLE) {
            mPasswordToggleView.setVisibility(View.GONE);
        }

        if (mPasswordToggleDummyDrawable != null) {
            // Make sure that we remove the dummy end compound drawable if it exists, and then
            // clear it
            final Drawable[] compounds = TextViewCompat.getCompoundDrawablesRelative(mEditText);
            if (compounds[2] == mPasswordToggleDummyDrawable) {
                TextViewCompat.setCompoundDrawablesRelative(mEditText, compounds[0], compounds[1],
                        mOriginalEditTextEndDrawable, compounds[3]);
                mPasswordToggleDummyDrawable = null;
            }
        }
    }
}