當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。