简体   繁体   English

Lottie动画与其在React Native中的容器相比非常小

[英]Lottie animation is very small compared to it's container in react native

I have an on click animation that is working perfectly, but I can't get the actual animated element to be more "zoomed" in. It looks like this: 我有一个点击动画效果很好,但是我无法使实际的动画元素更加“放大”。它看起来像这样:

在此处输入图片说明

Here's the code: 这是代码:

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>
    );
  }

there's nothing funny going on with the parent View, so I'm really confused as to why the heart isn't taking the full width and height of the Animation view. 父视图没有任何有趣的事情,所以我真的很困惑为什么心脏没有采用动画视图的全部宽度和高度。 This also makes placing this element next to either icons difficult. 这也使得将该元素放置在任一图标旁边很困难。

You can try add some properties of Lottie Animation: 您可以尝试添加Lottie Animation的一些属性:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM