2014-04-23 27 views
0

內調整圖像我是新來的Android和仍然在學習/具有XML什麼是XML

什麼是對XML內調整圖像的最佳途徑麻煩的最好辦法。

目前圖像的寬度和高度設置爲

android:layout_width="wrap_content" 
android:layout_height="wrap_content" 

這對於大多數的屏幕尺寸,但豈有或大或小的確定,它要麼充滿了太多的屏幕起來還是不夠的。 設置它的最佳方式是什麼,以便圖像是一個設定的大小,但是可以縮放到顯示的任何屏幕上? 我希望它成爲所有尺寸不大的所有設備尺寸的設置尺寸,其他設備尺寸不大。我真的很難在XML中設置東西,因此非常感謝所有幫助。

感謝

回答

1

試試這個..

<ImageView android:id="@+id/image_view"  
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:adjustViewBounds="true" 
    android:maxWidth="42dp" 
    android:maxHeight="42dp" 
    android:scaleType="fitCenter" 
    android:layout_marginLeft="3dp" 
    android:src="@drawable/icon" 
    /> 

添加屬性的android:scaleType = 「fitCenter」 和android:adjustViewBounds = 「真」

我相信你想使用android:scaleType="fitXY"

查看此SQ問題:How works android ImageView android:scaleType="fitXY" property?