의 항목이있는 ListView
이 있는데, 설명의 편의를 위해. 이미지를 너비 '행의 크기로 조정하고 가로 세로 비율을 유지합니다. 여기 ListView
의 단순화 된 버전의 항목 레이아웃의 ImageView
최대 너비를 확장하는 ListView의 ImageView
<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>
의 폭이 match_parent
이다가, 그리고 그것의 모든 조상은 동일합니다. 레이아웃 디자이너는 ImageView
의 크기가 전체 너비에 걸쳐 있지만 내부의 이미지는 그렇지 않다는 것을 보여줍니다.
편집 : 이미지의 크기가 올바르게 조정됩니다. 문제는 목록 뷰 행의 너비가 너비가 올바른 크기로 조정될 수 없기 때문입니다. fitXY
을 사용하면 너비가 조정되지만 가로 세로 비율이 올바르지 않습니다.
어떤 아이디어가 있습니까? 덕분에 .
나는 모든 다양한 유형을 시도했습니다. –
어댑터 뷰 요소는 내부에 뭔가를 넣을 때까지 아무런 크기가 없다는 문제가 있습니다. 그래서 닭고기와 계란입니다. listview 크기는 자식에 맞게 셀이지만 자식 이미지 뷰는 컨테이너의 크기에 맞게 크기를 조정하려고합니다. –