下面列出了android.graphics.PorterDuff#Mode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public final void drawColor(@ColorInt int color, @NonNull PorterDuff.Mode mode) {
nDrawColor(mNativeCanvasWrapper, color, mode.nativeInt);
}
/**
* Specifies the blending mode used to apply the tint specified by
* {@link #setTrackTintList(ColorStateList)}} to the track drawable.
* The default mode is {@link PorterDuff.Mode#SRC_IN}.
*
* @param tintMode the blending mode used to apply the tint, may be
* {@code null} to clear tint
* @attr ref android.R.styleable#Switch_trackTintMode
* @see #getTrackTintMode()
* @see Drawable#setTintMode(PorterDuff.Mode)
*/
public void setTrackTintMode(@Nullable PorterDuff.Mode tintMode) {
mTrackTintMode = tintMode;
mHasTrackTintMode = true;
applyTrackTint();
}
/**
* Specifies the blending mode used to apply the tint specified by
* {@link #setThumbTintList(ColorStateList)}} to the thumb drawable.
* The default mode is {@link PorterDuff.Mode#SRC_IN}.
*
* @param tintMode the blending mode used to apply the tint, may be
* {@code null} to clear tint
* @attr ref android.R.styleable#Switch_thumbTintMode
* @see #getThumbTintMode()
* @see Drawable#setTintMode(PorterDuff.Mode)
*/
public void setThumbTintMode(@Nullable PorterDuff.Mode tintMode) {
mThumbTintMode = tintMode;
mHasThumbTintMode = true;
applyThumbTint();
}
/**
* Specifies the blending mode used to apply the tint specified by
* {@link #setImageTintList(ColorStateList)}} to the image drawable. The default
* mode is {@link PorterDuff.Mode#SRC_IN}.
*
* @param tintMode the blending mode used to apply the tint, may be
* {@code null} to clear tint
* @attr ref android.R.styleable#ImageView_tintMode
* @see #getImageTintMode()
* @see Drawable#setTintMode(PorterDuff.Mode)
*/
public void setImageTintMode(@Nullable PorterDuff.Mode tintMode) {
mDrawableTintMode = tintMode;
mHasDrawableTintMode = true;
applyImageTint();
}
/**
* Specifies the blending mode used to apply the tint specified by
* {@link #setSecondaryProgressTintList(ColorStateList)}} to the secondary
* progress indicator. The default mode is
* {@link PorterDuff.Mode#SRC_ATOP}.
*
* @param tintMode the blending mode used to apply the tint, may be
* {@code null} to clear tint
* @attr ref android.R.styleable#ProgressBar_secondaryProgressTintMode
* @see #setSecondaryProgressTintList(ColorStateList)
* @see Drawable#setTintMode(PorterDuff.Mode)
*/
public void setSecondaryProgressTintMode(@Nullable PorterDuff.Mode tintMode) {
if (mProgressTintInfo == null) {
mProgressTintInfo = new ProgressTintInfo();
}
mProgressTintInfo.mSecondaryProgressTintMode = tintMode;
mProgressTintInfo.mHasSecondaryProgressTintMode = true;
if (mProgressDrawable != null) {
applySecondaryProgressTint();
}
}
/**
* Specifies the blending mode used to apply the tint specified by
* {@link #setThumbTintList(ColorStateList)}} to the thumb drawable. The
* default mode is {@link PorterDuff.Mode#SRC_IN}.
*
* @param tintMode the blending mode used to apply the tint, may be
* {@code null} to clear tint
*
* @attr ref android.R.styleable#SeekBar_thumbTintMode
* @see #getThumbTintMode()
* @see Drawable#setTintMode(PorterDuff.Mode)
*/
public void setThumbTintMode(@Nullable PorterDuff.Mode tintMode) {
mThumbTintMode = tintMode;
mHasThumbTintMode = true;
applyThumbTint();
}
/**
* Specifies the blending mode used to apply the tint specified by
* {@link #setIndeterminateTintList(ColorStateList)} to the indeterminate
* drawable. The default mode is {@link PorterDuff.Mode#SRC_IN}.
*
* @param tintMode the blending mode used to apply the tint, may be
* {@code null} to clear tint
* @attr ref android.R.styleable#ProgressBar_indeterminateTintMode
* @see #setIndeterminateTintList(ColorStateList)
* @see Drawable#setTintMode(PorterDuff.Mode)
*/
public void setIndeterminateTintMode(@Nullable PorterDuff.Mode tintMode) {
if (mProgressTintInfo == null) {
mProgressTintInfo = new ProgressTintInfo();
}
mProgressTintInfo.mIndeterminateTintMode = tintMode;
mProgressTintInfo.mHasIndeterminateTintMode = true;
applyIndeterminateTint();
}
/**
* Specifies the blending mode used to apply the tint specified by
* {@link #setCheckMarkTintList(ColorStateList)} to the check mark
* drawable. The default mode is {@link PorterDuff.Mode#SRC_IN}.
*
* @param tintMode the blending mode used to apply the tint, may be
* {@code null} to clear tint
* @attr ref android.R.styleable#CheckedTextView_checkMarkTintMode
* @see #setCheckMarkTintList(ColorStateList)
* @see Drawable#setTintMode(PorterDuff.Mode)
*/
public void setCheckMarkTintMode(@Nullable PorterDuff.Mode tintMode) {
mCheckMarkTintMode = tintMode;
mHasCheckMarkTintMode = true;
applyCheckMarkTint();
}
/**
* @return the blending mode used to apply the tint to the progress
* background
* @attr ref android.R.styleable#ProgressBar_progressBackgroundTintMode
* @see #setProgressBackgroundTintMode(PorterDuff.Mode)
*/
@Nullable
public PorterDuff.Mode getProgressBackgroundTintMode() {
return mProgressTintInfo != null ? mProgressTintInfo.mProgressBackgroundTintMode : null;
}
/**
* Returns the {@link android.graphics.PorterDuff.Mode} for the selected tint mode option.
*
* @return selected tint mode
*/
public PorterDuff.Mode getTintMode() {
return MODES[mBlendSpinner.getSelectedItemPosition()];
}
/**
* Specifies the blending mode used to apply the tint specified by
* {@link #setIconTintList(ColorStateList)} to this item's icon. The default mode is
* {@link PorterDuff.Mode#SRC_IN}.
*
* @param tintMode the blending mode used to apply the tint, may be
* {@code null} to clear tint
* @attr ref android.R.styleable#MenuItem_iconTintMode
* @see #setIconTintList(ColorStateList)
* @see Drawable#setTintMode(PorterDuff.Mode)
*/
public default MenuItem setIconTintMode(@Nullable PorterDuff.Mode tintMode) { return this; }
/**
* Returns the blending mode used to apply the tint to this item's icon, if specified.
*
* @return the blending mode used to apply the tint to this item's icon
* @attr ref android.R.styleable#MenuItem_iconTintMode
* @see #setIconTintMode(PorterDuff.Mode)
*/
@Nullable
public default PorterDuff.Mode getIconTintMode() { return null; }
/**
* Returns the blending mode used to apply the tint to the secondary
* progress drawable, if specified.
*
* @return the blending mode used to apply the tint to the secondary
* progress drawable
* @attr ref android.R.styleable#ProgressBar_secondaryProgressTintMode
* @see #setSecondaryProgressTintMode(PorterDuff.Mode)
*/
@Nullable
public PorterDuff.Mode getSecondaryProgressTintMode() {
return mProgressTintInfo != null ? mProgressTintInfo.mSecondaryProgressTintMode : null;
}
/**
* @return the blending mode used to apply the tint to the track
* drawable
* @attr ref android.R.styleable#Switch_trackTintMode
* @see #setTrackTintMode(PorterDuff.Mode)
*/
@Nullable
public PorterDuff.Mode getTrackTintMode() {
return mTrackTintMode;
}
/**
* @return the blending mode used to apply the tint to the thumb
* drawable
* @attr ref android.R.styleable#Switch_thumbTintMode
* @see #setThumbTintMode(PorterDuff.Mode)
*/
@Nullable
public PorterDuff.Mode getThumbTintMode() {
return mThumbTintMode;
}
/**
* Sets a tinting option for the image.
*
* @param color Color tint to apply.
* @param mode How to apply the color. The standard mode is
* {@link PorterDuff.Mode#SRC_ATOP}
*
* @attr ref android.R.styleable#ImageView_tint
*/
public final void setColorFilter(int color, PorterDuff.Mode mode) {
setColorFilter(new PorterDuffColorFilter(color, mode));
}
/**
* @hide
* Equivalent to calling
* {@link Drawable#setColorFilter(int, android.graphics.PorterDuff.Mode)},
* on the {@link Drawable} of a given view.
* <p>
*
* @param viewId The id of the view that contains the target
* {@link Drawable}
* @param targetBackground If true, apply these parameters to the
* {@link Drawable} returned by
* {@link android.view.View#getBackground()}. Otherwise, assume
* the target view is an {@link ImageView} and apply them to
* {@link ImageView#getDrawable()}.
* @param colorFilter Specify a color for a
* {@link android.graphics.ColorFilter} for this drawable. This will be ignored if
* {@code mode} is {@code null}.
* @param mode Specify a PorterDuff mode for this drawable, or null to leave
* unchanged.
*/
public void setDrawableTint(int viewId, boolean targetBackground,
int colorFilter, @NonNull PorterDuff.Mode mode) {
addAction(new SetDrawableTint(viewId, targetBackground, colorFilter, mode));
}
/**
* @return the blending mode used to apply the tint to the button drawable
* @attr ref android.R.styleable#CompoundButton_buttonTintMode
* @see #setButtonTintMode(PorterDuff.Mode)
*/
@Nullable
public PorterDuff.Mode getButtonTintMode() {
return mButtonTintMode;
}
/**
* Returns the blending mode used to apply the tint to the thumb drawable,
* if specified.
*
* @return the blending mode used to apply the tint to the thumb drawable
* @attr ref android.R.styleable#SeekBar_thumbTintMode
* @see #setThumbTintMode(PorterDuff.Mode)
*/
@Nullable
public PorterDuff.Mode getThumbTintMode() {
return mThumbTintMode;
}
/**
* Returns the blending mode used to apply the tint to the tick mark drawable,
* if specified.
*
* @return the blending mode used to apply the tint to the tick mark drawable
* @attr ref android.R.styleable#SeekBar_tickMarkTintMode
* @see #setTickMarkTintMode(PorterDuff.Mode)
*/
@Nullable
public PorterDuff.Mode getTickMarkTintMode() {
return mTickMarkTintMode;
}