本文整理汇总了Java中android.widget.ImageView.setImageTintList方法的典型用法代码示例。如果您正苦于以下问题:Java ImageView.setImageTintList方法的具体用法?Java ImageView.setImageTintList怎么用?Java ImageView.setImageTintList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ImageView
的用法示例。
在下文中一共展示了ImageView.setImageTintList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setBottomIconOriColor
import android.widget.ImageView; //导入方法依赖的package包/类
private void setBottomIconOriColor(BottomNavigationView bottomView) {
try {
Field mMenuViewField = BottomNavigationView.class.getDeclaredField("mMenuView");
mMenuViewField.setAccessible(true);
BottomNavigationMenuView mMenuView = (BottomNavigationMenuView) mMenuViewField.get(bottomView);
Field mButtonsField = BottomNavigationMenuView.class.getDeclaredField("mButtons");
mButtonsField.setAccessible(true);
BottomNavigationItemView[] mButtons = (BottomNavigationItemView[]) mButtonsField.get(mMenuView);
Field mIconField = BottomNavigationItemView.class.getDeclaredField("mIcon");
mIconField.setAccessible(true);
for (BottomNavigationItemView item : mButtons) {
ImageView mIcon = (ImageView) mIconField.get(item);
mIcon.setImageTintList(null);
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: show
import android.widget.ImageView; //导入方法依赖的package包/类
public static void show(Context context, CharSequence charSequence, int type) {
View layout;
if (toast == null) {
toast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
initToast(toast);
layout = LayoutInflater.from(context).inflate(R.layout.base_toast, null);
((TextView) layout.findViewById(R.id.base_toast_text_view)).setText(charSequence);
toast.setView(layout);
toast.setGravity(Gravity.TOP, 0, 0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
toast.getView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
} else {
layout = toast.getView();
}
TextView titleView = find(layout, R.id.base_toast_text_view);
ImageView imageView = find(layout, R.id.base_toast_image_view);
if (titleView != null) {
titleView.setText(charSequence);
}
if (imageView != null) {
if (type == TYPE_NONE) {
imageView.setVisibility(View.GONE);
} else {
imageView.setVisibility(View.VISIBLE);
switch (type % 4) {
case TYPE_OK:
imageView.setImageResource(R.drawable.base_ok);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
imageView.setImageTintList(ColorStateList.valueOf(SkinHelper.getSkin().getThemeSubColor()));
}
break;
case TYPE_INFO:
imageView.setImageResource(R.drawable.base_info);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
imageView.setImageTintList(ColorStateList.valueOf(SkinHelper.getSkin().getThemeSubColor()));
}
break;
case TYPE_ERROR:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
imageView.setImageTintList(ColorStateList.valueOf(Color.parseColor("#d62119")));
}
imageView.setImageResource(R.drawable.base_failed_red);
break;
}
}
}
toast.show();
}