How to display .gif file in imageview?

后端 未结 8 1742
无人及你
无人及你 2020-12-13 20:26

My layout have lots of imageviews. I want to show .gif animated file in just one imageview. I tried Yash method (Adding gif image in an ImageView in android) but .gif file s

相关标签:
8条回答
  • 2020-12-13 21:21

    Unfortunately a gif will not animation inside of an ImageView on its own. You will have to create a new subclass of View to handle this for you.

    Show .gif with android.graphics.Movie

    0 讨论(0)
  • 2020-12-13 21:23

    If you don't want to use Glide, just add this to your dependencies and create your unique 'gif'. Check for the latest version before use. ImageView:

    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'
    

    Works very efficiently with minimal lines of code. An example is:

    <pl.droidsonroids.gif.GifImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/dancer"
            android:src="@drawable/maddancer" />
    
    0 讨论(0)
提交回复
热议问题