Search code examples
javaandroidpicasso

Got different ImageView sizes using ListView


i have got an strange issue, in my ListView, I've got an ImageView, which should have specifed by me size. Everything works just fine in the avd, but in real device, it's getting weird because of different sizes of ImageView. What should I do with it?

Initialization of ImageView

<ImageView
        android:id="@+id/hourly_weatherIcon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:layout_marginStart="15dp" />

Here I set up the ImageView

 ImageView weatherIcon = view.findViewById(R.id.hourly_weatherIcon);
 utils.setWeatherIcon(model.getForecastID(), weatherIcon);

Following with this Picasso method

    String url = "https://openweathermap.org/img/w/";
    String fileExtension = ".png";
    String finalUrl = url + forecast + fileExtension;
    Picasso.get().load(finalUrl).resize(250,250).into(imageView);

Here's what it's look like 1 2


Solution

  • Try to djust the width and height of the image manually in xml, then apply scaleType="centerCrop" attribute