因此对于ImageView,有一个返回背景drawable的imageView.getBackground()。有没有办法像这样以编程方式获取src drawable?
以下是我的意思的一个小例子:
main.xml的片段
...
<ImageView
android:id="@+id/main_iv"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/imageSrc"
android:background="@drawable/imageBG" />
...
爪哇
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
}
...
}