0

anyone knows how can I to make all that images from my list to have the same size/form, more exactly I want all my images to have the square form.

Here is my both XML, sry but I cant post the code here because it's to big and don't let me

Horatiu Dum
  • 31
  • 2
  • 7

5 Answers5

1

Maybe we can refer to this question : How to resize Image in Android?

You may make an array of all your images and than itarete thorugh this array and use the method shown below on all of your files.

Bitmap yourBitmap;
Bitmap resized = Bitmap.createScaledBitmap(yourBitmap, newWidth, newHeight, true);
Community
  • 1
  • 1
Recomer
  • 178
  • 2
  • 12
  • I don't want that kind of resize because I've already use it. But it don't help me for my problem, but make my images more little. – Horatiu Dum Sep 04 '15 at 17:19
  • It doesn't have to be more little,i guess.You can specify the exact sizes in newWidth and newHeight.Am I missing something? – Recomer Sep 04 '15 at 17:26
1

If you're using a list, you're probably using a custom adapter to inflate the list with the elements (http://developer.android.com/guide/topics/ui/declaring-layout.html#AdapterViews).
So you could just adjust your "listitem.xml" file, so that every created list element has the same size.

Something like:

<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>
Big_Chair
  • 2,781
  • 3
  • 31
  • 58
0

Couldnt you set it in your xml to have a set height/ width and presumably height to also = width? If its like this you might be doing wrap content.

Ashley Alvarado
  • 1,078
  • 10
  • 17
0

In lisitem XML layout set imagview height to fixed dp like 150,200 dp. Hope this will help you.

Priya Singhal
  • 1,261
  • 11
  • 16
0

try this

<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" />
Thamays
  • 2,978
  • 26
  • 31