0

How to display Animated Gif in Imageview I had Used Gif from Drawable folder its not Displying like Gif. Nee Help plz

Here is m my Imageview Code

    <ImageView
            android:layout_width="40dp"
            android:id="@+id/ivGif"
            android:src="@drawable/success_bg"
            android:layout_height="40dp"
            android:gravity="center|bottom"
            android:visibility="visible" />
Darshan Khatri
  • 317
  • 3
  • 15

3 Answers3

2

Use this library

compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.3'

<pl.droidsonroids.gif.GifImageView
        android:id="@+id/gif_iv"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:scaleType="centerCrop"
        android:src="@drawable/ic_ani_gif"
        app:layout_anchor="@+id/rl_holder_view"
        app:layout_anchorGravity="center|top" />
Aman
  • 458
  • 4
  • 16
1

i just used this code and its working first add library

compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.3'

then set gif layout where you want to put gif like this

<pl.droidsonroids.gif.GifTextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/your_gif"/>
Darshan Khatri
  • 317
  • 3
  • 15
0

Try this one :

 "android.resource://[package]/[res id]"

    Uri myUri =("android.resource://" + context.getPackageName() + "/"
                        + R.drwable.mygifimage);
    try{
        Url myUrl = myUri.toURL();
        webView wView = new webView(this);   
        wView.loadUrl(myUrl);
        setContentView(view);

       }catch(Exception e){
              e.printStackTrace()
       }
jason
  • 6,962
  • 36
  • 117
  • 198