因此,我從Web服務加載圖像,但圖像的大小有時比其他圖像的大小要小,並且可視化看起來很愚蠢我把它們放在Android的ListView中。我想修復ImageView的大小,使其只顯示圖像的一部分,如果它大於預設的數量。我嘗試了所有我能想到的設置setMaxWidth/setMaxHeight,將縮放類型設置爲centerCrop,使用ClipableDrawable封裝我的BitmapDrawable,使用Drawable.setBounds()進行設置。我試着用XML和編程方式設置,但都沒有成功。我很驚訝設置最大寬度/高度沒有做任何事情。以下是我在佈局文件中使用ImageView定義的XML:無論位圖的大小如何使我的ImageView成爲固定大小
<ImageView android:id="@+id/recipeImage"
android:maxHeight="64px"
android:maxWidth="64px"
android:scaleType="centerCrop"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="6dip"/>
沒有任何工作。 Oooooouweee什麼與dat? :-)
我可以發誓我試過了。謝謝你的幫助。 – chubbsondubs 2010-09-27 13:24:41
'minHeight'和'minWidth'如何? – 2016-09-13 22:39:24