Solve Problem/React Native

[React Native] Gif 파일 표시하기

안다희 2020. 5. 5. 00:41
728x90

gif 파일을 표시해보자.

 

 

- iOS

따로 할거 없음!

대신, gif를 적용했을 때 조금 느리게 렌더링될 수 있으므로, fast image 라이브러리를 이용하는게 좋다.

github.com/DylanVann/react-native-fast-image

 

DylanVann/react-native-fast-image

🚩 FastImage, performant React Native image component. - DylanVann/react-native-fast-image

github.com

 

 

- Android

android/app/build.gradle - dependencies에 추가

    implementation 'com.facebook.fresco:fresco:1.+'
    implementation 'com.facebook.fresco:animated-gif:1.+'

 

- Usage

<Image
  source={require('./motion.gif')} // first way (local)
  // source={{uri: 'http://www.clicktorelease.com/code/gif/1.gif'}} // second way (http)
  width={200}
  height={200}
/>

 

 

 

[출처]

https://www.it-swarm.dev/ko/react-native/react-%EB%84%A4%EC%9D%B4%ED%8B%B0%EB%B8%8C%EC%97%90%EC%84%9C-%EC%95%A0%EB%8B%88%EB%A9%94%EC%9D%B4%EC%85%98-gif%EB%A5%BC-%ED%91%9C%EC%8B%9C%ED%95%98%EB%A0%A4%EB%A9%B4-%EC%96%B4%EB%96%BB%EA%B2%8C%ED%95%A9%EB%8B%88%EA%B9%8C/823910415/

 

react-native — React 네이티브에서 애니메이션 GIF를 표시하려면 어떻게합니까?

기본적으로 Gif 이미지는 Android 네이티브 앱 반응)에서 지원되지 않습니다. GIF 이미지를 표시하려면 Fresco 를 사용하도록 설정해야합니다. Android/app/build.gradle 파일을 작성하고 다음 코드를 추가하십시오. dependencies: { ... compile 'com.facebook.fresco:fresco:1.+' // For animated GIF support compile 'com.facebook.fresco:ani

www.it-swarm.dev

 

출처: https://mingos-habitat.tistory.com/34 [밍고의서식지:티스토리]