【问题标题】:React-Native Touchableopacity not wrapping properlyReact-Native Touchableopacity 没有正确包装
【发布时间】:2018-10-05 10:05:04
【问题描述】:

我正在渲染平面列表,我根据索引渲染了一些图像。

所以它看起来像这样:https://ibb.co/ep2zye

我正在像这样渲染平面列表的左侧:

if(index % 2 == 0){

            return {
                marginTop: -SCREEN_WIDTH/12 + -(index-2)*SCREEN_WIDTH/20,
                marginRight: SCREEN_WIDTH / 35,
                marginLeft: SCREEN_WIDTH / 35,
                margin: SCREEN_WIDTH / 50,
                width: this.width,
                height: this.height,
                opacity: this.state.opacity,
                borderRadius: SCREEN_WIDTH / 36,
            }
        }

渲染看起来像这样:

return (
            <Animated.View pointerEvents={this.state.pointer}>
                <TouchableOpacity onPress={this.captureAnimation.bind(this, item, index)} style={{backgroundColor: 'darkred'}}>
                    <AnimatedImage source={{uri: 'http://' + item.info.picture_path}} style={this.renderStyle(index)}/>
                    <View style={{position: 'absolute', bottom: SCREEN_WIDTH/20, left: SCREEN_WIDTH/24, width: '80%'}}>
                        <Text style={{fontSize: SCREEN_WIDTH / 27, color: '#ffffff',fontWeight: 'bold'}}>{item.info.title} </Text>
                        <Text style={{fontSize: SCREEN_WIDTH / 42, color: '#ffffff',fontWeight: 'bold'}}> {item.date} </Text>
                    </View>
                </TouchableOpacity>
            </Animated.View>
        );

所以我不明白为什么,可触摸的不透明度没有包裹所有图像,而不是包裹其中的一部分?即使我做marginTop,touchableopacity应该是包装它不是吗?谁能告诉我这里出了什么问题?

【问题讨论】:

  • 不,我并不是说动画。我的问题是,如果它一直包裹着想象,为什么 touchableopacity 区域会变小?
  • +++ 没有 cmets?没有解决办法?

标签: css react-native


【解决方案1】:

我通过将整个数组分成 2 个来解决它,然后在左侧和右侧渲染它们中的每一个。是的,现在它应该是这样,但它仍然没有解释为什么它在我展示的示例中不起作用..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-05
    • 2019-06-17
    • 1970-01-01
    • 2019-06-26
    相关资源
    最近更新 更多