The code is simple:
<ImageView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/cat"/>
Notice the ImageView used fill_parent
for width and height.
The image cat
is a small image and it will be zoomed in to fit the ImageView, and keep the width/height ratio at the same time.
My question is how to get the displayed size of the image? I tried:
imageView.getDrawable().getIntrinsicHeight()
But which it the original height of the image cat
.
I tried:
imageView.getDrawable().getBounds()
But which returns Rect(0,0,0,0)
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…