当前位置: 首页>>代码示例>>Java>>正文


Java ImageView.setImageTintList方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:iAcn,项目名称:MBEStyle,代码行数:23,代码来源:MainActivity.java

示例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();
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:52,代码来源:T2.java


注:本文中的android.widget.ImageView.setImageTintList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。