本文整理匯總了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();
}