How do I display an animated gif in React Native?

前端 未结 8 1160
逝去的感伤
逝去的感伤 2020-12-02 22:10

How can I display an animated gif in react native. This is what I\'ve tried.

It works fine with a .

8条回答
  •  情歌与酒
    2020-12-02 23:00

    To add gif and WebP in your project you need some optional modules. If the RN version is <=0.59 then add the following lines in your android/app/build.gradle file.

    dependencies {
      // If your app supports Android versions before Ice Cream Sandwich (API level 14)
      compile 'com.facebook.fresco:animated-base-support:1.10.0'
    
      // For animated GIF support
      compile 'com.facebook.fresco:animated-gif:1.10.0'
    
      // For WebP support, including animated WebP
      compile 'com.facebook.fresco:animated-webp:1.10.0'
      compile 'com.facebook.fresco:webpsupport:1.10.0'
    
      // For WebP support, without animations
      compile 'com.facebook.fresco:webpsupport:1.10.0'
    }
    

    If the RN version is 0.60 and greater then add the following lines in android/app/build.gradle file

    dependencies {
      // If your app supports Android versions before Ice Cream Sandwich (API level 14)
      implementation 'com.facebook.fresco:animated-base-support:1.10.0'
    
      // For animated GIF support
      implementation 'com.facebook.fresco:animated-gif:1.12.0'
    
      // For WebP support, including animated WebP
      implementation 'com.facebook.fresco:animated-webp:1.10.0'
      implementation 'com.facebook.fresco:webpsupport:1.10.0'
    
      // For WebP support, without animations
      implementation 'com.facebook.fresco:webpsupport:1.10.0'
    }
    

提交回复
热议问题