安卓ImageView获取图片信息比较

        //获取当前图片ConstantState类对象
        Drawable.ConstantState constantState = mIv_njlb.getDrawable().getCurrent().getConstantState();
        //获取需要比较的图片ConstantState类对象
        Drawable.ConstantState t2 = getDrawable(R.mipmap.xiala).getConstantState();
        if (constantState.equals(t2)) {
            mIv_njlb.setImageResource(R.mipmap.shangla);
        } else {
            mIv_njlb.setImageResource(R.mipmap.xiala);
        }

猜你喜欢

转载自blog.csdn.net/weixin_33737774/article/details/86782990