Android ImageView 获取图片信息后进行比较

Posted imluzhi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android ImageView 获取图片信息后进行比较相关的知识,希望对你有一定的参考价值。

                ImageView a=(ImageView)findViewById(R.id.imageView2);
                //获取当前图片ConstantState类对象
                Drawable.ConstantState t1=  a.getDrawable().getCurrent().getConstantState();
                //找到需要比较的图片ConstantState类对象
                Drawable.ConstantState t2=getDrawable(R.drawable.ok).getConstantState();
                if(t1.equals(t2))
                {
                    a.setImageResource(R.drawable.ok2);
                }
                else{
                    a.setImageResource(R.drawable.ok);
                }

 

以上是关于Android ImageView 获取图片信息后进行比较的主要内容,如果未能解决你的问题,请参考以下文章