2014-03-04 4 views
1

ListView에 표시되는 이미지가 많이 있습니다.비율이 3 : 2 인 ImageView의 이미지

내 list_view_item.xml (ivEventImage에서 이미지) :

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_height="wrap_content" 
android:layout_width="match_parent"> 

    <TextView 
     android:id="@+id/tvText" 
     android:autoLink="web" 
     android:linksClickable="true" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

    <ImageView 
     android:id="@+id/ivEventImage" 
     android:adjustViewBounds="true" 
     android:scaleType="fitXY" 
     android:src="@null" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

그들은 서로 다른 크기의이 - 640 × 480, 1280 × 720, 1920 × 1080, 1080x1920 및 다른 사람을. 다른 크기 이외에, 다른 방향 - 초상화 또는 가로. 모든 이미지가 다른 종횡비로 표시됩니다.

가로 세로 비율이 3 : 2이고 이미지 높이가 이미지의 가운데 부분 만 표시하기에 부적합한 경우 ImageView에서 이미지를 표시하는 방법. 그러나 비율을 깨지 말라.

검은 색 사각형 - ivEventImage. 왼쪽 - 1280x720, 오른쪽 - 1080x1920 (예 :). imageView problem

답변

3

사용 centerCrop 대신 다음과 같이 android:scaleType에 대한 fitXY ...

android:scaleType="centerCrop" 

그래서, ImageView XML이 될 것입니다 ...

<ImageView 
    android:id="@+id/ivEventImage" 
    android:adjustViewBounds="true" 
    android:scaleType="centerCrop" 
    android:src="@null" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 
관련 문제