Class GifTextureView

java.lang.Object
android.view.View
android.view.TextureView
pl.droidsonroids.gif.GifTextureView
All Implemented Interfaces:
Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback

public class GifTextureView
extends TextureView

TextureView which can display animated GIFs. GifTextureView can only be used in a hardware accelerated window. When rendered in software, GifTextureView will draw nothing.

GIF source can be specified in XML or by calling setInputSource(InputSource)

 
     <pl.droidsonroids.gif.GifTextureView
          xmlns:app="http://schemas.android.com/apk/res-auto"
          android:id="@+id/gif_texture_view"
          android:scaleType="fitEnd"
          app:gifSource="@drawable/animation"
          android:layout_width="match_parent"
          android:layout_height="match_parent"> 
 
Note that src attribute comes from app namespace (you can call it whatever you want) not from android one. Drawable, raw, mipmap resources and assets can be specified through XML. If value is a string (referenced from resources or entered directly) it will be treated as an asset.

Unlike TextureView GifTextureView is transparent by default, but it can be changed by setOpaque(boolean). You can use scale types the same way as in ImageView.