2014-04-15 81 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的伎俩。它将图片缩放为全宽,并允许高度滚动,同时仍保持纵横比。