Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image is stretched vertically while using Glide in Grid View Android

I made an app that displays images stored locally in a grid view.I used to use Picasso but i stopped using it due to many issues(It didn't load images on some devices).Then i switched to glide,everything is fine except that the image is stretched vertically. This causes scrolling issue.I never faced such an issue while using Picasso.How can i fix this issue ???

My MainActivity code-

 Glide.with(MainActivity.this)
                    .load(mThumbIds[position])
                    .placeholder(R.raw.place_holder)
                    .error(R.raw.big_problem)
                    .centerCrop()
                    .into(imageView);
            return imageView;

My activity_main.xml file code

  <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:background="@color/colorPrimary"
    android:layout_height="match_parent">

    <GridView
    android:id="@+id/gridview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:columnWidth="150dp"
    android:numColumns="2"
    android:layout_above="@+id/adView" />

    <com.google.android.gms.ads.AdView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/adView"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="@string/banner_ad_unit_id"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true">
    </com.google.android.gms.ads.AdView>

 </RelativeLayout>

Screenshot of the problem-See the image on the right it is stretched vertically

like image 204
Sukrit Kumar Avatar asked Nov 30 '25 05:11

Sukrit Kumar


1 Answers

I just found out. It's because size of placeholder image didn't match original image.

My solution was simply remove placeholder or resize your placeholder

like image 128
Bara Timur Avatar answered Dec 01 '25 20:12

Bara Timur