本文整理匯總了Java中android.support.v4.graphics.drawable.DrawableCompat.setTintMode方法的典型用法代碼示例。如果您正苦於以下問題:Java DrawableCompat.setTintMode方法的具體用法?Java DrawableCompat.setTintMode怎麽用?Java DrawableCompat.setTintMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.graphics.drawable.DrawableCompat
的用法示例。
在下文中一共展示了DrawableCompat.setTintMode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: applyPasswordToggleTint
import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
private void applyPasswordToggleTint() {
if (mPasswordToggleDrawable != null
&& (mHasPasswordToggleTintList || mHasPasswordToggleTintMode)) {
mPasswordToggleDrawable = DrawableCompat.wrap(mPasswordToggleDrawable).mutate();
if (mHasPasswordToggleTintList) {
DrawableCompat.setTintList(mPasswordToggleDrawable, mPasswordToggleTintList);
}
if (mHasPasswordToggleTintMode) {
DrawableCompat.setTintMode(mPasswordToggleDrawable, mPasswordToggleTintMode);
}
if (mPasswordToggleView != null
&& mPasswordToggleView.getDrawable() != mPasswordToggleDrawable) {
mPasswordToggleView.setImageDrawable(mPasswordToggleDrawable);
}
}
}
示例2: applyButtonTint
import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
void applyButtonTint() {
Drawable buttonDrawable = CompoundButtonCompat.getButtonDrawable(this.mView);
if (buttonDrawable == null) {
return;
}
if (this.mHasButtonTint || this.mHasButtonTintMode) {
buttonDrawable = DrawableCompat.wrap(buttonDrawable).mutate();
if (this.mHasButtonTint) {
DrawableCompat.setTintList(buttonDrawable, this.mButtonTintList);
}
if (this.mHasButtonTintMode) {
DrawableCompat.setTintMode(buttonDrawable, this.mButtonTintMode);
}
if (buttonDrawable.isStateful()) {
buttonDrawable.setState(this.mView.getDrawableState());
}
this.mView.setButtonDrawable(buttonDrawable);
}
}
示例3: setBackgroundDrawable
import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
void setBackgroundDrawable(ColorStateList backgroundTint, Mode backgroundTintMode, int rippleColor, int borderWidth) {
Drawable[] layers;
this.mShapeDrawable = DrawableCompat.wrap(createShapeDrawable());
DrawableCompat.setTintList(this.mShapeDrawable, backgroundTint);
if (backgroundTintMode != null) {
DrawableCompat.setTintMode(this.mShapeDrawable, backgroundTintMode);
}
this.mRippleDrawable = DrawableCompat.wrap(createShapeDrawable());
DrawableCompat.setTintList(this.mRippleDrawable, createColorStateList(rippleColor));
if (borderWidth > 0) {
this.mBorderDrawable = createBorderDrawable(borderWidth, backgroundTint);
layers = new Drawable[]{this.mBorderDrawable, this.mShapeDrawable, this.mRippleDrawable};
} else {
this.mBorderDrawable = null;
layers = new Drawable[]{this.mShapeDrawable, this.mRippleDrawable};
}
this.mContentBackground = new LayerDrawable(layers);
this.mShadowDrawable = new ShadowDrawableWrapper(this.mView.getResources(), this.mContentBackground, this.mShadowViewDelegate.getRadius(), this.mElevation, this.mElevation + this.mPressedTranslationZ);
this.mShadowDrawable.setAddPaddingForCorners(false);
this.mShadowViewDelegate.setBackgroundDrawable(this.mShadowDrawable);
}
示例4: forIdWithColors
import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
public static Drawable forIdWithColors(Context context, int blackDrawableId, int baseId, int disabledId, int pressedId, int selectedId) {
Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(context, blackDrawableId));
int baseColor = ContextCompat.getColor(context, baseId);
int disabledColor = ContextCompat.getColor(context, disabledId);
int pressedColor = ContextCompat.getColor(context, pressedId);
int selectedColor = ContextCompat.getColor(context, selectedId);
int[][] states = new int[4][];
states[0] = new int[]{-android.R.attr.state_enabled};
states[1] = new int[]{android.R.attr.state_pressed};
states[2] = new int[]{android.R.attr.state_selected};
states[3] = new int[]{android.R.attr.state_enabled};
DrawableCompat.setTintList(drawable, new ColorStateList(states, new int[]{disabledColor, pressedColor, selectedColor, baseColor}));
DrawableCompat.setTintMode(drawable, Mode.SRC_IN);
return drawable;
}
示例5: colorDrawableWrapped
import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
/**
* Colors the given drawable to the specified color set using the drawable wrapping technique ({@link DrawableCompat#wrap(Drawable)}).
* This method also uses {@link PorterDuff.Mode#SRC_ATOP} to color the pixels.
*
* @param drawable Which drawable to color
* @param colorStates Which color set to use
* @return A colored drawable, cached instance in most cases
*/
@NonNull
public static Drawable colorDrawableWrapped(@NonNull final Drawable drawable, @NonNull final ColorStateList colorStates) {
Drawable wrapped = DrawableCompat.wrap(drawable);
DrawableCompat.setTintList(wrapped, colorStates);
DrawableCompat.setTintMode(wrapped, PorterDuff.Mode.SRC_ATOP);
wrapped = DrawableCompat.unwrap(wrapped);
return wrapped;
}
示例6: tintDrawable
import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
public static Drawable tintDrawable(Drawable drawable, ColorStateList cls, PorterDuff.Mode mode) {
if (drawable == null) return null;
Drawable wrapper = DrawableCompat.wrap(drawable.mutate());
DrawableCompat.setTintList(wrapper, cls);
DrawableCompat.setTintMode(drawable, mode);
return wrapper;
}
示例7: setTintMode
import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
@SuppressLint("RestrictedApi")
private static void setTintMode(Drawable drawable, PorterDuff.Mode mode) {
if (drawable instanceof TintAwareDrawable) {
((TintAwareDrawable) drawable).setTintMode(mode);
} else {
DrawableCompat.setTintMode(drawable, mode);
}
}
示例8: createTintedDrawable
import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
@CheckResult
@Nullable
public static Drawable createTintedDrawable(@Nullable Drawable drawable, @ColorInt int color) {
if (drawable == null) return null;
drawable = DrawableCompat.wrap(drawable.mutate());
DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN);
DrawableCompat.setTint(drawable, color);
return drawable;
}
示例9: forIdStateList
import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
public static Drawable forIdStateList(Context context, int drawableId, int colorStateListId) {
Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(context, drawableId));
DrawableCompat.setTintList(drawable, ContextCompat.getColorStateList(context, colorStateListId));
DrawableCompat.setTintMode(drawable, Mode.SRC_IN);
return drawable;
}
示例10: tintDrawable
import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
public static Drawable tintDrawable(Drawable drawable, int tintColor) {
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable, tintColor);
DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN);
return drawable;
}
示例11: setTintMode
import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
/**
*/
@Override
public void setTintMode(@NonNull PorterDuff.Mode tintMode) {
DrawableCompat.setTintMode(mDrawable, tintMode);
}
示例12: bindView
import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
@Override
public void bindView(GridItem.ViewHolder holder, List payloads)
{
super.bindView(holder, payloads);
if (holder.itemView.getLayoutParams() != null)
{
LayoutParams params = new LayoutParams(holder.itemView.getLayoutParams());
params.column = column;
params.row = row;
holder.itemView.setLayoutParams(params);
}
holder.textView.setText(model != null && isStart ? model.getName() : "");
/*if (model != null)
{
int resolvedColor = model.getItemColor() != -1 ? model.getItemColor() : holder.itemView.getResources().getColor(R.color.today_color);
holder.itemView.setBackground(
getTintedDrawable(
holder.itemView.getContext(),
holder.itemView.getResources().getDrawable(isToday ? R.drawable.item_today_bg : R.drawable.item_bg),
isToday ? 0 : resolvedColor));
}
else
*/
if(model != null)
{
Drawable drawable = ContextCompat.getDrawable(holder.itemView.getContext(), isToday ? R.drawable.item_today_bg : R.drawable.item_bg).mutate();
if(!isToday)
{
Drawable wrapDrawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(wrapDrawable, model.getItemColor());
DrawableCompat.setTintMode(wrapDrawable, PorterDuff.Mode.OVERLAY);
holder.itemView.setBackground(wrapDrawable);
}
holder.itemView.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
model.onClick(view);
}
});
}
else
holder.itemView.setBackgroundResource(isToday ? R.drawable.item_today_bg : isWeekend ? R.drawable.item_weekend_bg : R.drawable.item_bg);
}
示例13: setTintMode
import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
@Override
public void setTintMode(PorterDuff.Mode tintMode) {
DrawableCompat.setTintMode(mDrawable, tintMode);
}
示例14: setBackgroundTintMode
import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
void setBackgroundTintMode(Mode tintMode) {
if (this.mShapeDrawable != null) {
DrawableCompat.setTintMode(this.mShapeDrawable, tintMode);
}
}
示例15: setBackgroundTintMode
import android.support.v4.graphics.drawable.DrawableCompat; //導入方法依賴的package包/類
void setBackgroundTintMode(PorterDuff.Mode tintMode) {
if (mShapeDrawable != null) {
DrawableCompat.setTintMode(mShapeDrawable, tintMode);
}
}