2013-07-24 21 views
1

因爲我用它作爲動畫背景,所以在ImageView中有很大的圖像。如何顯示圖片以使其高度填充整個父元素並顯示寬度與屏幕寬度一樣多?如何在Android中的ImageView中僅顯示部分圖片的寬度?

我試圖使這個使用此代碼:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    tools:context=".MainActivity" > 

<ImageView 
     android:id="@+id/background" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:src="@drawable/background" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true"/> 

</RelativeLayout> 

,但它不工作。它只是在屏幕上顯示整幅圖片,調整屏幕的寬度。我在哪裏弄錯了?

回答

1

你嘗試過這樣的事情:

How to display a part of an image?

,或者你可以使用android縮放

Use android:scaleType="centerInside" 
+0

我做它與「centerCrop」,但不幸的是我失去的圖像與,所以當我想在x軸上進行翻譯時,我只有一部分位於中心的圖片。 – Tommz

相關問題