本文整理匯總了Java中android.graphics.drawable.Drawable.setTintList方法的典型用法代碼示例。如果您正苦於以下問題:Java Drawable.setTintList方法的具體用法?Java Drawable.setTintList怎麽用?Java Drawable.setTintList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.drawable.Drawable
的用法示例。
在下文中一共展示了Drawable.setTintList方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: applyIconTint
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
* Applies tint specified for the given <var>configuration</var> object to the given <var>icon</var>
* drawable.
*
* @param icon The icon drawable to which to apply the tint.
* @param configuration Configuration object carrying tint list and tint mode used to apply tint
* to the icon drawable.
* @return Icon drawable with applied tint. For pre {@link Build.VERSION_CODES#LOLLIPOP LOLLIPOP}
* the icon drawable will be wrapped in {@link TintDrawable} to support tinting feature.
*/
@SuppressLint("NewApi")
private static Drawable applyIconTint(Drawable icon, ItemConfiguration configuration) {
if (UiConfig.MATERIALIZED) {
if (configuration.iconTintListSpecified) {
icon.setTintList(configuration.iconTintList);
}
if (configuration.iconTintModeSpecified) {
icon.setTintMode(configuration.iconTintMode);
}
} else {
final TintDrawable tintIcon = icon instanceof TintDrawable ? (TintDrawable) icon : new TintDrawable(icon);
if (configuration.iconTintListSpecified) {
tintIcon.setTintList(configuration.iconTintList);
}
if (configuration.iconTintModeSpecified) {
tintIcon.setTintMode(configuration.iconTintMode);
}
icon = tintIcon;
}
return icon;
}
示例2: getIconForBackground
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public Drawable getIconForBackground(Context context, int background) {
if (mIsIconLarge) {
// Only small icons should be tinted.
return mIconDrawable;
}
mIconColor = IconPalette.resolveContrastColor(context, mIconColor, background);
Drawable icon = mIconDrawable.mutate();
// DrawableContainer ignores the color filter if it's already set, so clear it first to
// get it set and invalidated properly.
icon.setTintList(null);
icon.setTint(mIconColor);
return icon;
}
示例3: setTintList
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public static void setTintList(Drawable drawable, ColorStateList tint) {
drawable.setTintList(tint);
}