本文整理匯總了Java中android.graphics.drawable.Drawable.setTintMode方法的典型用法代碼示例。如果您正苦於以下問題:Java Drawable.setTintMode方法的具體用法?Java Drawable.setTintMode怎麽用?Java Drawable.setTintMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.drawable.Drawable
的用法示例。
在下文中一共展示了Drawable.setTintMode方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: setTintMode
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public static void setTintMode(Drawable drawable, Mode tintMode) {
drawable.setTintMode(tintMode);
}