2014-04-15 82 views
1

我有一個簡單的應用程序ImageViewAndroid ImageView風景 - 肖像

我需要圖像採取所有寬度和滾動y如果它不適合。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" > 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:adjustViewBounds="true" 
     android:scaleType="center" 
     android:id="@+id/myPic" 
     android:contentDescription="@string/page_label" /> 
</RelativeLayout> 

一切都是完美的,但是當我切換到橫向圖像不會採取一切寬,有空格(左,右)。

只ImageView.ScaleType CENTER_CROP幫助,但它從頂部和底部削減piecies。 是否有可能使它在景觀中的工作方式相同?

+0

嘗試在您的ScrollView中添加android:fillViewPort =「true」 –

+0

未找到包'android'中屬性'fillViewPort'的資源標識符 – user3536513

+0

http://developer.android.com/reference/android/widget/ScrollView.html –

回答

0

scaletype fitCenter爲ImageView的伎倆。它將圖片縮放爲全寬,並允許高度滾動,同時仍保持縱橫比。