Search code examples
androidgifpicassoandroid-glideanimated-gif

Having troubles loading a GIF image in my application


so i was trying to load a GIF image using a link into my application, but i couldn't find how.

i tried using Glide and Picasso but i still couldn't resolve my problem, at first i thought i might have something in my app that's stopping the GIF from loading so i tried creating a new app just to test loading a GIF in an app and still couldn't load a single GIF.

I have looked around for a question like mine and tested some of the answers given but none of them worked!

so if anyone can show me a way to load a GIF in an app i would be quite thankful, and i can share the code for my app but as i stated earlier i am trying a new empty app and has no actual code in it.


Solution

  • There's too little information to know what happened. It would be better to show more detail about the code you tried and the result.

    However, This is a Simple Example

    AndroidManifest.xml:

    add internet permission

    <uses-permission android:name="android.permission.INTERNET" />
    

    build.gradle(:app):

    add Glide Library.

    implementation 'com.github.bumptech.glide:glide:4.12.0'
    

    activity_main.xml:

    add an ImageView

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    

    MainActivity.kt:

    load GIF into imageView

     val url = "https://media.giphy.com/media/3o7527pa7qs9kCG78A/giphy.gif"
     Glide.with(this)
         .load(url)
         .into(imageView)