gradientDrawable.setColor(selected_color); gradientDrawable.setCornerRadius(cornerRadius); selected = new InsetDrawable(gradientDrawable, paddingStartEnd, paddingTopBottom, paddingStartEnd, paddingTopBottom); gradientMask.setColor(Color.BLACK); gradientMask.setCornerRadius(cornerRadius); Drawable mask = new InsetDrawable(gradientMask, paddingStartEnd, paddingTopBottom, paddingStartEnd, paddingTopBottom); touchDrawable.setColor(UIUtils.getThemeColor(ctx, R.attr.colorControlHighlight)); touchDrawable.setCornerRadius(cornerRadius); Drawable touchInsetDrawable = new InsetDrawable(touchDrawable, paddingStartEnd, paddingTopBottom, paddingStartEnd, paddingTopBottom);
@Override protected void onUpdateBackgroundAndPaddings(Rect searchBarBounds, Rect padding) { // Apply the top-bottom padding to the content itself so that the launcher transition is // clipped correctly mContent.setPadding(0, padding.top, 0, padding.bottom); // TODO: Use quantum_panel_dark instead of quantum_panel_shape_dark. InsetDrawable background = new InsetDrawable( getResources().getDrawable(R.drawable.quantum_panel_shape_dark), padding.left, 0, padding.right, 0); Rect bgPadding = new Rect(); background.getPadding(bgPadding); mView.setBackground(background); getRevealView().setBackground(background.getConstantState().newDrawable()); mView.updateBackgroundPadding(bgPadding); }
public static Drawable insetBitmap(@NonNull Context context, @NonNull Bitmap bitmap) { BitmapDrawable bitmapDrawable = new BitmapDrawable(context.getResources(), bitmap); bitmapDrawable.setBounds(0, 0, bitmapDrawable.getIntrinsicWidth(), bitmapDrawable.getIntrinsicHeight()); int inset = (DisplayUtils.getScreenWidth(context) - bitmapDrawable.getBounds().right) / 2; if (inset <= 0) { return bitmapDrawable; } InsetDrawable insetDrawable = new InsetDrawable(bitmapDrawable, inset, 0, inset, 0); insetDrawable.setBounds(0, 0, DisplayUtils.getScreenWidth(context), bitmapDrawable.getIntrinsicHeight()); return insetDrawable; } }
InsetDrawable drawable = (InsetDrawable) myButton.getBackground(); GradientDrawable shape = (GradientDrawable) drawable.getDrawable(); shape.setColor(Color.BLUE);
@Override public void draw(Canvas canvas) { copyBounds(mTmpRect); canvas.save(); // Layout direction must be obtained from the activity. final boolean isLayoutRTL = ViewCompat.getLayoutDirection( mActivity.getWindow().getDecorView()) == ViewCompat.LAYOUT_DIRECTION_RTL; final int flipRtl = isLayoutRTL ? -1 : 1; final int width = mTmpRect.width(); canvas.translate(-mOffset * width * mPosition * flipRtl, 0); // Force auto-mirroring if it's not supported by the platform. if (isLayoutRTL && !mHasMirroring) { canvas.translate(width, 0); canvas.scale(-1, 1); } super.draw(canvas); canvas.restore(); } }
InsetDrawable background = new InsetDrawable( getResources().getDrawable(R.drawable.quantum_panel_shape), padding.left, 0, padding.right, 0); Rect bgPadding = new Rect(); background.getPadding(bgPadding); mContainerView.setBackground(background); mRevealView.setBackground(background.getConstantState().newDrawable()); mAppsRecyclerView.updateBackgroundPadding(bgPadding); mAdapter.updateBackgroundPadding(bgPadding);
RelativeLayout rl = (RelativeLayout)findViewById(R.id.circle_layoutinner); InsetDrawable id = (InsetDrawable)rl.getBackground(); GradientDrawable gd = (GradientDrawable)id.getDrawable(); // API 19+ only! gd.setColor(0xffff0000); // set to red
private static InsetDrawable createRelativeInsetDrawable(Drawable drawable, int insetStart, int insetTop, int insetEnd, int insetBottom, boolean isRtl) { if (isRtl) { return new InsetDrawable(drawable, insetEnd, insetTop, insetStart, insetBottom); } else { return new InsetDrawable(drawable, insetStart, insetTop, insetEnd, insetBottom); } } }
/** */ @Override @SuppressLint("NewApi") public Drawable getCurrent() { if (mDrawable instanceof InsetDrawable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { final Drawable innerDrawable = ((InsetDrawable) mDrawable).getDrawable(); return innerDrawable != null ? innerDrawable.getCurrent() : null; } return mDrawable.getCurrent(); }
public static Drawable getThreeDots(Context context){ Drawable drawable = ContextCompat.getDrawable(context, R.drawable.sample_three_icons); //Add padding to too large icon return new InsetDrawable(drawable, 100, 0, 100, 0); }
/** */ @Override @SuppressLint("NewApi") public Drawable getCurrent() { if (mDrawable instanceof InsetDrawable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { final Drawable innerDrawable = ((InsetDrawable) mDrawable).getDrawable(); return innerDrawable != null ? innerDrawable.getCurrent() : null; } return mDrawable.getCurrent(); }
/** * Update the background for the reveal view and content view based on the background padding. */ protected void updateBackground(int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) { mRevealView.setBackground(new InsetDrawable(mBaseDrawable, paddingLeft, paddingTop, paddingRight, paddingBottom)); mContent.setBackground(new InsetDrawable(mBaseDrawable, paddingLeft, paddingTop, paddingRight, paddingBottom)); }
/** */ @Override @SuppressLint("NewApi") public Drawable getCurrent() { if (mDrawable instanceof InsetDrawable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { final Drawable innerDrawable = ((InsetDrawable) mDrawable).getDrawable(); return innerDrawable != null ? innerDrawable.getCurrent() : null; } return mDrawable.getCurrent(); }
public static InsetDrawable create(final @NonNull Drawable drawable, final int insetLeft, final int insetTop, final int insetRight, final int insetBottom) { if (NEEDS_FIXING) { return new XpInsetDrawable(drawable, insetLeft, insetTop, insetRight, insetBottom); } else { return new InsetDrawable(drawable, insetLeft, insetTop, insetRight, insetBottom); } }
public static InsetDrawable create(final @NonNull Drawable drawable, final int inset) { if (NEEDS_FIXING) { return new XpInsetDrawable(drawable, inset); } else { return new InsetDrawable(drawable, inset); } }
private void updateBarColorAndInset() { Drawable drawable; if (!RecyclerFastScrollerUtils.isRTL(getContext())) { drawable = new InsetDrawable(new ColorDrawable(mBarColor), mBarInset, 0, 0, 0); } else { drawable = new InsetDrawable(new ColorDrawable(mBarColor), 0, 0, mBarInset, 0); } drawable.setAlpha(57); RecyclerFastScrollerUtils.setViewBackground(mBar, drawable); }
private void updateHandleColorsAndInset() { StateListDrawable drawable = new StateListDrawable(); if (!RecyclerFastScrollerUtils.isRTL(getContext())) { drawable.addState(View.PRESSED_ENABLED_STATE_SET, new InsetDrawable(new ColorDrawable(mHandlePressedColor), mBarInset, 0, 0, 0)); drawable.addState(View.EMPTY_STATE_SET, new InsetDrawable(new ColorDrawable(mHandleNormalColor), mBarInset, 0, 0, 0)); } else { drawable.addState(View.PRESSED_ENABLED_STATE_SET, new InsetDrawable(new ColorDrawable(mHandlePressedColor), 0, 0, mBarInset, 0)); drawable.addState(View.EMPTY_STATE_SET, new InsetDrawable(new ColorDrawable(mHandleNormalColor), 0, 0, mBarInset, 0)); } RecyclerFastScrollerUtils.setViewBackground(mHandle, drawable); }
@Override protected void updateBackground( int paddingLeft, int paddingTop, int paddingRight, int paddingBottom) { if (mLauncher.getDeviceProfile().isVerticalBarLayout()) { getRevealView().setBackground(new InsetDrawable(mBaseDrawable, paddingLeft, paddingTop, paddingRight, paddingBottom)); getContentView().setBackground( new InsetDrawable(new ColorDrawable(Color.TRANSPARENT), paddingLeft, paddingTop, paddingRight, paddingBottom)); } else { getRevealView().setBackground(mBaseDrawable); } }
InsetDrawable checkmarkInset = new InsetDrawable(checkmark, Utils.dpToPx(5)); drawable = new LayerDrawable(new Drawable[]{ colorChoiceDrawable,
@Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { Drawable d = new BitmapDrawable(getView().getResources(), resource); d = new InsetDrawable(d, dpToPx(ICON_MARGIN)); getView().setCompoundDrawablesWithIntrinsicBounds(d, null, null, null); } }