How do I display an animated gif in React Native?

前端 未结 8 1137
逝去的感伤
逝去的感伤 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 22:58

    For React Native 0.60 and higher

    Open your android/app/build.gradle file and add following lines to first of dependencies section

    implementation 'com.facebook.fresco:fresco:2.0.0'
    implementation 'com.facebook.fresco:animated-gif:2.0.0'
    

    And then

    cd android
    gradlew clean
    react-native run-android
    
    0 讨论(0)
  • 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'
    }
    
    0 讨论(0)
提交回复
热议问题