获得ImageView的机器人相关的图像(可绘制) [英] Get associated image (Drawable) in ImageView android
本文介绍了获得ImageView的机器人相关的图像(可绘制)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一个图像设置为Android的一个ImageView的控制:
i set a image to a imageview control in android:
iv.setImageResource(R.drawable.image1);
我想获得此相关的绘制对象,是这样的:
i want to get this associated Drawable, looks like:
Drawable myDrawable = iv.getImageResource(); //wrong
谢谢!
推荐答案
您可以像
Drawable myDrawable = iv.getDrawable();
您可以像绘制资源进行比较
You can compare it with a drawable resource like
if(iv.getDrawable()==getResources().getDrawable(R.drawable.image1)){
//do work here
}
这篇关于获得ImageView的机器人相关的图像(可绘制)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文