I have a simple widget containing an ImageView
. I'd like to fetch an image from the web and display it in the ImageView
while maintaining the aspect ratio.
Here's the layout definition for the widget:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/quality_image"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_below="@+id/widget_icon"
android:layout_marginBottom="@dimen/widget_spacing"
android:scaleType="fitXY" />
</LinearLayout>
..and this is the image in question:
I'd like the image to always fit the height of the ImageView
. This bit has been easy. If the width of the ImageView
is less than that of the image, I don't mind if the image gets cropped horizontally as long as the aspect ratio is maintained. I've set the maximum size of the widget to never be more than the size of the image so we don't have to worry about cases when the height of the ImageView
is more than the image.
I'm terribly lost with this and have begin wondering if this is even possible since there doesn't seem to be way to access the widget dimensions. Sometimes the most trivial things bog you down.