2013-01-09 44 views
0

我有一個可繪製的,我想要顯示。我希望它水平放置屏幕,並且可以垂直滾動(當其高度大於屏幕時),同時保持縮放。可繪製:使其適合屏幕,並可滾動

我把drawable放入ImageView。 drawable是可變的(不同高度和寬度的圖片)。我可以縮放每個drawable以適應屏幕的寬度,但是當我繪製的drawable高於屏幕時,會在頂部切割,並且在ScrollView的底部會出現黑色條紋。

我試過每個ScrollView和ImageView的組合,我都能想到,但圖像要麼拉伸要麼是其中的一部分掉下來。任何幫助深表感謝!

我當前的代碼:

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_gravity="center" > 

    <ImageView 
     android:id="@+id/iv1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:scaleType="center" /> 

</ScrollView> 

回答

0
<ImageView 
    android:id="@+id/iv1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:scaleType="centerInside" 
    android:adjustViewBounds="true" 
/> 

但我不知道這是能比父母高圖像更大。如果這沒有幫助,我會嘗試在我的歸檔工作解決方案中找到。

+0

可能是縮放類型應該是centerCrop而不是centerInside。查看http://developer.android.com/reference/android/widget/ImageView.ScaleType.html – Preethi