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);
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); } } }
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); }
/** * 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)); }
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); } }
InsetDrawable checkmarkInset = new InsetDrawable(checkmark, Utils.dpToPx(5)); drawable = new LayerDrawable(new Drawable[]{ colorChoiceDrawable,
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = inflater.getContext(); final Resources res = context.getResources(); final View view = inflater.inflate(R.layout.fragment_directory, container, false); mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar); mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty); mListView = (ListView) view.findViewById(R.id.list); mListView.setOnItemClickListener(mItemListener); mListView.setMultiChoiceModeListener(mMultiListener); mListView.setRecyclerListener(mRecycleListener); // Indent our list divider to align with text final Drawable divider = mListView.getDivider(); final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left); final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset); if (insetLeft) { mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0)); } else { mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0)); } mGridView = (GridView) view.findViewById(R.id.grid); mGridView.setOnItemClickListener(mItemListener); mGridView.setMultiChoiceModeListener(mMultiListener); mGridView.setRecyclerListener(mRecycleListener); return view; }
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; } }
@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); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { final Resources res = getActivity().getResources(); fab = (FloatingActionButton)view.findViewById(R.id.fab); fab.setOnClickListener(this); if(isTelevision()){ fab.setVisibility(View.GONE); } mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar); mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty); mListView = (ListView) view.findViewById(R.id.list); mListView.setOnItemClickListener(mItemListener); if(isTelevision()) { mListView.setOnItemLongClickListener(mItemLongClickListener); } fab.attachToListView(mListView); // Indent our list divider to align with text final Drawable divider = mListView.getDivider(); final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left); final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset); if (insetLeft) { mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0)); } else { mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0)); } }
back.addState(new int[]{-android.R.attr.state_checked}, backu); back.addState(StateSet.WILD_CARD, trk); mTrackDrawable = new InsetDrawable(back, 0, (int) (density), 0, (int) (density));
InsetDrawable background = new InsetDrawable( getResources().getDrawable(R.drawable.quantum_panel_shape), padding.left, 0, padding.right, 0);
mRevealDrawable = new InsetDrawable(mBaseDrawable, mContainerPaddingLeft, mContainerPaddingTop, mContainerPaddingRight, mContainerPaddingBottom);
mRevealDrawable = new InsetDrawable(mBaseDrawable, mContainerPaddingLeft, mContainerPaddingTop, mContainerPaddingRight, mContainerPaddingBottom);