javascript - 与 React Native 中的容器相比,Lottie 动画非常小

标签 javascript animation react-native lottie

我有一个运行完美的点击动画,但我无法让实际的动画元素更加“放大”。它看起来像这样:

enter image description here

代码如下:

import { Animated, TouchableHighlight } from 'react-native';
import Animation from 'lottie-react-native';

    // a bunch of code here
  render() {
    return (
      <TouchableHighlight
        onPress={this.animate}
        underlayColor="transparent"
      >
        <Animation
          style={{
            backgroundColor: 'red',
            width: 150,
            height: 150,
          }}
          source={favoriteHeart}
          progress={this.state.progress}
        />
      </TouchableHighlight>
    );
  }

父 View 没有发生任何有趣的事情,所以我真的很困惑为什么心脏没有占据动画 View 的完整宽度和高度。这也使得将此元素放置在任一图标旁边变得困难。

最佳答案

您可以尝试添加 Lottie Animation 的一些属性:

<Animation
   style={{
       backgroundColor: 'red',
       width: 150,
       height: 150,
   }}
   source={favoriteHeart}
   progress={this.state.progress}
   resizeMode = 'cover'
 />

关于javascript - 与 React Native 中的容器相比,Lottie 动画非常小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48016824/

相关文章:

reactjs - 使用react-native安装本地包作为依赖项

javascript - 我可以在单个组件中进行多次提取吗?

javascript - 仅当结果不是对象/数组时,导入模块上的 Typescript 单元测试才有效

android - 将过渡添加到 AnimationDrawable

google-chrome - Google Chrome 高度动画的奇怪行为

react-native - 在 React Native 上生成 apk 失败

android - React native android 不使用 react-native-device-info 编译

javascript - 如何在 PhantomJS 脚本中将 customHeaders 作为系统参数传递?

javascript - Chrome 和火狐浏览器 : pictures stick together

css - 单击外部按钮扩展搜索栏