Код прост:
<ImageView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/cat"/>
Обратите внимание, что ImageView использовал fill_parent
для ширины и высоты.
Изображение cat
представляет собой небольшое изображение, и оно будет увеличено, чтобы соответствовать ImageView, и одновременно поддерживать соотношение ширины и высоты.
Мой вопрос в том, как получить отображаемый размер изображения? Я пробовал:
imageView.getDrawable().getIntrinsicHeight()
Но какая из них оригинальная высота изображения cat
.
Я пробовал:
imageView.getDrawable().getBounds()
Но возвращает Rect(0,0,0,0)
.