代码很简单:
<ImageView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/cat"/>
注意ImageView使用了fill_parent
来设置宽度和高度。
图片cat
很小,会被放大以适应ImageView,并保持宽高比。
我的问题是如何获取图像的显示尺寸?我尝试过:
imageView.getDrawable().getIntrinsicHeight()
但是猫图片的原始高度是多少呢?
我尝试过:
imageView.getDrawable().getBounds()
但是它返回了Rect(0,0,0,0)
。