2013-02-20 80 views
0

本質上,我正在尋找像scaleType =「centerCrop」之類的東西,而不是中心。ImageView佈局

如果屏幕尺寸大於ImageView,我無法正確顯示。我試圖顯示一個ImageView,它開始top=0left=0並且沒有縮放。沒關係,圖像不適合在屏幕上。現在我有它的相對佈局:

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

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/postagram_blank_large"/> 
</RelativeLayout> 

我的RelativeLayout高度和寬度使用wrap_content嘗試。我也玩過scaleType以及使用ScrollviewScrollView的問題在於圖像比顯示端口更高更寬(這也是意味着發生)。

我該如何做這項工作?

+0

您是否嘗試過的最高級別的線性佈局?次要音符取向在相對佈局上不做任何事情。 – 2013-02-20 02:05:52

+0

@GabeSechan這並沒有解決問題。並且是的,取向什麼也不做,只是當我替換對LL的嘗試時。 – jjNford 2013-02-20 02:10:41

+0

嘗試強制圖像的比例類型居中 – 2013-02-20 02:12:34

回答

1

難道android:background會將圖像縮放到屏幕尺寸?請嘗試使用android:src

+0

這應該是一個評論... – 2013-02-20 02:12:57

+0

@SimonSays這與scaleType =「centerCrop」一起工作,但我不希望圖像居中。 – jjNford 2013-02-20 02:20:27

0

試試這個:的

<ImageView 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent" 
    android:src="@drawable/postagram_blank_large" 
    android:scaleType="matrix" 
    /> 

wrap_content代替fill_parent也適用,使用任何你想要的