public void tintMessageBackground(@ColorInt int color) { Drawable drawable = Utils.tinting(ContextCompat.getDrawable(getContext(), R.drawable.round), color); ViewCompat.setBackground(mOval, drawable); ViewCompat.setBackground(mMessages, drawable); }
public void style(TextView badgeTextView, ColorStateList colorStateList) { Context ctx = badgeTextView.getContext(); //set background for badge if (mBadgeBackground == null) { ViewCompat.setBackground(badgeTextView, new BadgeDrawableBuilder(this).build(ctx)); } else { ViewCompat.setBackground(badgeTextView, mBadgeBackground); } //set the badge text color if (mTextColor != null) { ColorHolder.applyToOr(mTextColor, badgeTextView, null); } else if (mTextColorStateList != null) { badgeTextView.setTextColor(mTextColorStateList); } else if (colorStateList != null) { badgeTextView.setTextColor(colorStateList); } //set the padding int paddingLeftRight = mPaddingLeftRight.asPixel(ctx); int paddingTopBottom = mPaddingTopBottom.asPixel(ctx); badgeTextView.setPadding(paddingLeftRight, paddingTopBottom, paddingLeftRight, paddingTopBottom); //set the min width badgeTextView.setMinWidth(mMinWidth.asPixel(ctx)); } }
/** * binds the data of this item onto the viewHolder * * @param viewHolder the viewHolder of this item */ @Override public void bindView(ViewHolder viewHolder, List<Object> payloads) { super.bindView(viewHolder, payloads); //get the context Context ctx = viewHolder.itemView.getContext(); //set the background for the item viewHolder.view.clearAnimation(); ViewCompat.setBackground(viewHolder.view, FastAdapterUIUtils.getSelectableBackground(ctx, Color.RED, true)); //set the text for the name StringHolder.applyTo(name, viewHolder.name); //set the text for the description or hide StringHolder.applyToOrHide(description, viewHolder.description); }
states.addState(new int[]{}, new ColorDrawable(Color.TRANSPARENT)); ViewCompat.setBackground(view, states); view.setForeground(unselected); } else { states.addState(new int[]{}, unselected); ViewCompat.setBackground(view, states);
@Override public void bindView(ViewHolder viewHolder, List<Object> payloads) { super.bindView(viewHolder, payloads); //get the context Context ctx = viewHolder.itemView.getContext(); //set the background for the item viewHolder.view.clearAnimation(); ViewCompat.setBackground(viewHolder.view, FastAdapterUIUtils.getSelectableBackground(ctx, Color.RED, true)); //set the text for the name StringHolder.applyTo(name, viewHolder.name); //set the text for the description or hide int selectedSubItems = 0; if (mSubSelectionProvider != null) selectedSubItems = mSubSelectionProvider.getSelectedSubItems(); StringHolder descr = new StringHolder(description.getText()); if (selectedSubItems > 0) descr.setText("Selected children: " + selectedSubItems + "/" + getSubItems().size()); StringHolder.applyToOrHide(descr, viewHolder.description); viewHolder.description.setTextColor(selectedSubItems == 0 ? Color.BLACK : Color.RED); }
/** * binds the data of this item onto the viewHolder * * @param viewHolder the viewHolder of this item */ @Override public void bindView(ViewHolder viewHolder, List<Object> payloads) { super.bindView(viewHolder, payloads); //get the context Context ctx = viewHolder.itemView.getContext(); //set the background for the item viewHolder.view.clearAnimation(); ViewCompat.setBackground(viewHolder.view, FastAdapterUIUtils.getSelectableBackground(ctx, Color.RED, true)); //set the text for the name StringHolder.applyTo(name, viewHolder.name); //set the text for the description or hide StringHolder.applyToOrHide(description, viewHolder.description); if (getSubItems() == null || getSubItems().size() == 0) { viewHolder.icon.setVisibility(View.GONE); } else { viewHolder.icon.setVisibility(View.VISIBLE); } if (isExpanded()) { ViewCompat.setRotation(viewHolder.icon, 0); } else { ViewCompat.setRotation(viewHolder.icon, 180); } }
int descriptionColor = ColorHolder.color(getDescriptionTextColor(), ctx, R.attr.material_drawer_primary_text, R.color.material_drawer_primary_text); ViewCompat.setBackground(viewHolder.view, UIUtils.getSelectableBackground(ctx, selectedColor, isSelectedBackgroundAnimated()));
private void setHeaderBackground(@NonNull Drawable drawable) { ViewCompat.setBackground(headerContentLayout, drawable); }
/** * helper method to set the background depending on the android version * * @param v * @param d */ @Deprecated @SuppressLint("NewApi") public static void setBackground(View v, Drawable d) { ViewCompat.setBackground(v, d); }
/** * helper method to set the background depending on the android version * * @param v * @param drawableRes */ public static void setBackground(View v, @DrawableRes int drawableRes) { ViewCompat.setBackground(v, ContextCompat.getDrawable(v.getContext(), drawableRes)); }
ViewHolder(@NonNull View itemView, @DrawableRes int activatedBackgroundResId) { super(itemView); time = itemView.findViewById(R.id.time); title = itemView.findViewById(R.id.title); persons = itemView.findViewById(R.id.persons); room = itemView.findViewById(R.id.room); itemView.setOnClickListener(this); if (activatedBackgroundResId != 0) { // Compose a new background drawable by combining the existing one with the activated background final Drawable existingBackground = itemView.getBackground(); final Drawable activatedBackground = ContextCompat.getDrawable(itemView.getContext(), activatedBackgroundResId); Drawable newBackground; if (existingBackground == null) { newBackground = activatedBackground; } else { // Clear the existing background drawable callback so it can be assigned to the LayerDrawable ViewCompat.setBackground(itemView, null); itemView.setBackgroundResource(0); newBackground = new LayerDrawable(new Drawable[]{existingBackground, activatedBackground}); } ViewCompat.setBackground(itemView, newBackground); } }
/** * Set the background color of the section bubble. * * @param color The background color for the section bubble */ public void setBubbleColor(@ColorInt int color) { bubbleColor = color; if (bubbleImage == null) { Drawable drawable = ContextCompat.getDrawable(getContext(), bubbleSize.drawableId); if (drawable != null) { bubbleImage = DrawableCompat.wrap(drawable); bubbleImage.mutate(); } } DrawableCompat.setTint(bubbleImage, bubbleColor); ViewCompat.setBackground(bubbleView, bubbleImage); }
void linkToScrollBar(MaterialScrollBar msb, boolean addSpace) { this.addSpace = addSpace; materialScrollBar = msb; if(addSpace) { size = Utils.getDP(15, this) + materialScrollBar.handleThumb.getWidth(); } else { size = Utils.getDP(2, this) + materialScrollBar.handleThumb.getWidth(); } ViewCompat.setBackground(this, ContextCompat.getDrawable(context, rtl ? R.drawable.indicator_ltr : R.drawable.indicator)); LayoutParams lp = new LayoutParams(Utils.getDP(getIndicatorWidth(), this), Utils.getDP(getIndicatorHeight(), this)); lp = refreshMargins(lp); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, getTextSize()); LayoutParams tvlp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); tvlp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); addView(textView, tvlp); ((GradientDrawable)getBackground()).setColor(msb.handleColor); if(rtl) { lp.addRule(ALIGN_LEFT, msb.getId()); } else { lp.addRule(ALIGN_RIGHT, msb.getId()); } ((ViewGroup)msb.getParent()).addView(this, lp); }
itemView.setTextColor(mTextColor); ViewCompat.setBackground(itemView, mItemBackground != null ? mItemBackground.getConstantState().newDrawable() : null); NavigationMenuTextItem item = (NavigationMenuTextItem) mItems.get(position);
ViewCompat.setBackground(view, DynamicDrawableUtils .colorizeDrawable(DynamicResourceUtils.getDrawable( context, R.drawable.ads_background),
@Override public void initialize(MenuItemImpl itemData, int menuType) { mItemData = itemData; setVisibility(itemData.isVisible() ? VISIBLE : GONE); if (getBackground() == null) { ViewCompat.setBackground(this, createDefaultBackground()); } setCheckable(itemData.isCheckable()); setChecked(itemData.isChecked()); setEnabled(itemData.isEnabled()); setTitle(itemData.getTitle()); setIcon(itemData.getIcon()); setActionView(itemData.getActionView()); setContentDescription(itemData.getContentDescription()); TooltipCompat.setTooltipText(this, itemData.getTooltipText()); adjustAppearance(); }
R.style.Widget_Drawer_NavigationView); ViewCompat.setBackground( this, a.getDrawable(R.styleable.DrawerNavigationView_android_background)); if (a.hasValue(R.styleable.DrawerNavigationView_elevation)) {