如何在TouchableOpacity中旋转图像

时间:2018-05-01 08:24:32

标签: react-native

我尝试在TouchableOpacity元素中旋转图像。我的代码在iOS上完美运行,但它在android上不起作用。

我的代码:

<View style={commonStyle.topArea}>
    <TouchableOpacity>
        <Image
        resizeMode="stretch"
        source={this.props.playerHand[0].image}
        style={[
            commonStyle.card,
            { transform: [{ rotate: '-10deg' }] },
        ]}
        />
    </TouchableOpacity>
    <TouchableOpacity>
        <Image
        resizeMode="stretch"
        source={this.props.playerHand[1].image}
        style={[commonStyle.card, { transform: [{ rotate: '0deg' }] }]}
        />
    </TouchableOpacity>
    <TouchableOpacity>
        <Image
        resizeMode="stretch"
        source={this.props.playerHand[2].image}
        style={[commonStyle.card, { transform: [{ rotate: '10deg' }] }]}
        />
    </TouchableOpacity>
</View>

结果

This is output

1 个答案:

答案 0 :(得分:0)

Android不支持溢出的观看次数。您可以改为增加容器的大小。在touchableopacity而不是图像上添加旋转,并将flex:1添加到您的&#34;顶部区域&#34;。

相关问题