当前位置: 首页>>代码示例>>Java>>正文


Java DrawableCompat.setTintMode方法代码示例

本文整理汇总了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);
    }
  }
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:19,代码来源:TextInputLayout.java

示例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);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:AppCompatCompoundButtonHelper.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:22,代码来源:FloatingActionButtonEclairMr1.java

示例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;
}
 
开发者ID:Bruno125,项目名称:Unofficial-Ups,代码行数:16,代码来源:ColorizedDrawable.java

示例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;
}
 
开发者ID:milosmns,项目名称:silly-android,代码行数:17,代码来源:Coloring.java

示例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;
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:8,代码来源:ThemeUtils.java

示例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);
    }
}
 
开发者ID:parkingwang,项目名称:vehicle-keyboard-android,代码行数:9,代码来源:DrawableTint.java

示例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;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:10,代码来源:TintHelper.java

示例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;
}
 
开发者ID:Bruno125,项目名称:Unofficial-Ups,代码行数:7,代码来源:ColorizedDrawable.java

示例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;
}
 
开发者ID:Suleiman19,项目名称:Android-O-Sample,代码行数:7,代码来源:UiUtils.java

示例11: setTintMode

import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
/**
 */
@Override
public void setTintMode(@NonNull PorterDuff.Mode tintMode) {
	DrawableCompat.setTintMode(mDrawable, tintMode);
}
 
开发者ID:universum-studios,项目名称:android_ui,代码行数:7,代码来源:DrawableWrapper.java

示例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);
}
 
开发者ID:paramsen,项目名称:gradle-module-dependency,代码行数:51,代码来源:GridItem.java

示例13: setTintMode

import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
@Override
public void setTintMode(PorterDuff.Mode tintMode) {
  DrawableCompat.setTintMode(mDrawable, tintMode);
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:5,代码来源:DrawableWrapper.java

示例14: setBackgroundTintMode

import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
void setBackgroundTintMode(Mode tintMode) {
    if (this.mShapeDrawable != null) {
        DrawableCompat.setTintMode(this.mShapeDrawable, tintMode);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:6,代码来源:FloatingActionButtonEclairMr1.java

示例15: setBackgroundTintMode

import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
void setBackgroundTintMode(PorterDuff.Mode tintMode) {
    if (mShapeDrawable != null) {
        DrawableCompat.setTintMode(mShapeDrawable, tintMode);
    }
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:6,代码来源:FloatingActionButtonImpl.java


注:本文中的android.support.v4.graphics.drawable.DrawableCompat.setTintMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。