Reputation: 115
I have an issue with the GIF Resizing.
My GIF dimensions is 136*136
px and I'm trying to load it into an image view (that has its width and height set as wrap_content
) using Glide library. But the GIF ends up taking the entire screen.
My XML file code snippet looks like below:
ImageView
android:id="@+id/loading_animation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:adjustViewBounds="true"
tools:src="@drawable/gif_loading_animation"
android:foregroundGravity="center" />
And My main activity code looks something like this:
Glide.with(getContext())
.load(R.drawable.gif_loading_animation)
.asGif()
.into(loadingAnimation);
Is there any solution to avoid resizing without using any hard code parameters width and height. :)
Upvotes: 2
Views: 1002
Reputation: 687
You can try using .override(Target.SIZE_ORIGINAL)
Glide.with(getContext())
.load(R.drawable.gif_loading_animation)
.asGif()
.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
.into(loadingAnimation);
Upvotes: 4