amrro
amrro

Reputation: 1526

Glide sometimes takes the whole Layout

Glide's behavior is unpredectable sometimes, while using the app sometimes the ImageView looks like this: screenshot

Just going back (to the parent activity) and come back, without restarting the app, to the same movie result, it appears fixed (supposed appearance) like this:

right ImageView

I don't why I have this behavior, here the xml code for the image view:

<ImageView
    android:elevation="4dp"
    android:src="@drawable/poster_sample"
    android:id="@+id/poster_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginLeft="24dp"
    android:layout_marginStart="14dp"
    android:scaleType="centerCrop"/>

Glide code:

Glide
    .with(getContext())
    .load(mMovieValues.get(MovieContract.MovieEntry.COL_POSTER_URL))
    .centerCrop()
    .into(mPoster);

Where is the problem? and how to fix that?

Upvotes: 0

Views: 258

Answers (1)

Atiq
Atiq

Reputation: 14825

You should give a fixed height and width to your ImageView and no need to use centerCrop

<ImageView
    android:elevation="4dp"
    android:src="@drawable/poster_sample"
    android:id="@+id/poster_image"
    android:layout_width="250dp"
    android:layout_height="150dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginLeft="24dp"
    android:layout_marginStart="14dp"/>

and remove CenterCrop from here too

Glide
.with(getContext())
.load(mMovieValues.get(MovieContract.MovieEntry.COL_POSTER_URL))
.into(mPoster);

Upvotes: 1

Related Questions