Java Code Examples for android.widget.ImageView.setImageTintList()
The following are Jave code examples for showing how to use
setImageTintList() of the
android.widget.ImageView
class.
You can vote up the examples you like. Your votes will be used in our system to get
more good examples.
+ Save this method
Example 1
Project: MBEStyle File: MainActivity.java View Source Code | 7 votes |
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(); } }
Example 2
Project: RLibrary File: T2.java View Source Code | 5 votes |
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(); }