2012-12-23 2 views
0

폭을 채우고 약 200dp 높이의 이미지에 정사각형 이미지 (즉, 약 315dp x 315dp)를 확대하는 데 문제가 있습니다.정사각형 이미지 뷰를 사각형 이미지 뷰로 올바르게 스케일하는 방법은 무엇입니까?

기본적으로 이미지의 가로 세로 비율을 더 직사각형 모양으로 조정하면 가로 세로 비율이 올바르게 유지됩니다. 어떤 아이디어?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" > 

    <ImageView 
     android:id="@+id/image" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_gravity="center" 
     android:adjustViewBounds="true" 
     android:scaleType="centerCrop" /> 

</LinearLayout> 

답변

0
It should be like that 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" > 
    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="200dp"> 
    <ImageView 
     android:id="@+id/image" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_gravity="center" 
     android:adjustViewBounds="true" 
     android:scaleType="fitXY" /> 
    </FrameLayout> 

</LinearLayout> 

FrameLayout이 당신이

수동 안드로이드 UI를 읽어야 당신과 함께 더 이상 도움이 필요하면, 이미지의 사이즈를 해결할 것입니다 : 여기에 내가 무엇을 시도했다입니다
관련 문제