i have a ListView
whose items are ImageView
s, for the sake of discussion. i want the image to scale to the width of the ListView
's rows, and maintain it's aspect ratio. here's a simplified version of the ListView
's item layout,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="4dp" >
<FrameLayout
android:id="@+id/page_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible" >
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/some_image" />
</FrameLayout>
</FrameLayout>
</LinearLayout>
the ImageView
's width is match_parent
, and all ancestors of it are the same. layout designer shows that the ImageView
's dimensions span the entire width, but the image inside does not.
EDIT: the image is scaling correctly. the problem is that the height of the list view row is such that the width can't scale to the right size. if i use fitXY
, it does scale the width, but then the aspect ratio is incorrect.
any ideas? thanks.