【发布时间】:2014-11-18 10:32:24
【问题描述】:
因此,对于 ImageView,有一个 imageView.getBackground() 返回背景可绘制对象。有没有办法像这样以编程方式获取 src 可绘制对象?
这是我的意思的一个小例子:
main.xml的sn-p
...
<ImageView
android:id="@+id/main_iv"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/imageSrc"
android:background="@drawable/imageBG" />
...
Java
public class ActivityMain extends Activity {
ImageView iv;
...
...
@Override
public void onCreate(Bundle sIS){
super.onCreate(sIS);
setContentView(R.layout.main);
iv = (ImageView)findViewById(R.id.main_iv);
Drawable bg = iv.getBackground();
// Drawable source = iv.getSource(); but this method does not exist
}
...
}
【问题讨论】:
标签: android imageview drawable src