2015-09-04 60 views
0

任何人都知道如何使我的list中的所有圖像具有相同的大小/形式,更確切地說,我希望我的所有圖像都具有方形形式。如何設置相同尺寸的所有圖像

這裏是我的both XML,SRY但我不能在這裏發佈的代碼,因爲它是到大,不要讓我

+0

如果我的答案是錯的,我們可以讓你列表XML? –

+0

設置一個固定的高度和寬度的imageview – 3xplore

+0

可能重複[如何調整圖像在Android?](http://stackoverflow.com/questions/10413659/how-to-resize-image-in-android) – Marcelo

回答

0

想不出你設置它在XML擁有一套高度/寬度想必高度也=寬度?如果它像這樣,你可能會做包裝內容。

1

也許我們可以參考一下這個問題:How to resize Image in Android?

您可以將您的所有圖像陣列比itarete thorugh這個數組和使用上的所有文件,如下圖所示的方法。

Bitmap yourBitmap; 
Bitmap resized = Bitmap.createScaledBitmap(yourBitmap, newWidth, newHeight, true); 
+0

我不希望這種調整大小,因爲我'已經使用它。但它不能幫助我解決我的問題,但讓我的圖像更少。 –

+0

它不一定要更小,我猜。你可以在newWidth和newHeight中指定確切的大小。我錯過了什麼? – Recomer

0

在lisitem XML佈局組imagview高度固定DP像150200 DP。 希望這會幫助你。

1

如果您使用的是列表,那麼您可能使用自定義適配器來使元素充氣(http://developer.android.com/guide/topics/ui/declaring-layout.html#AdapterViews)。
所以你可以調整你的「listitem.xml」文件,以便每個創建的列表元素具有相同的大小。

喜歡的東西:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="vertical"> 
<ImageView 
     android:layout_width="50dp" 
     android:layout_height="50dp" 
     android:id="@+id/imgID" 
     android:src="@drawable/src_img" 
     /> 

</LinearLayout> 
0

試試這個

<ImageView 
    android:id="@+id/image" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:adjustViewBounds="true" 
    android:scaleType="centerCrop" 
    android:src="@drawable/db_two" /> 
相關問題