説明のためにListView
、項目がImageView
s の があります。の行の幅に合わせて画像を拡大縮小し、ListView
縦横比を維持します。ListView
のアイテム レイアウトの簡略版を次に示します。
<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>
のImageView
幅はmatch_parent
で、その祖先はすべて同じです。レイアウト デザイナーは、ImageView
の寸法が幅全体に及ぶことを示していますが、内部の画像はそうではありません。
画像は正しくスケーリングされています。問題は、リスト ビューの行の高さが、幅を適切なサイズに調整できないことです。を使用するfitXY
と、幅は拡大縮小されますが、縦横比が正しくありません。
何か案は?