react-native snap carousel在Android中放入ScrollView react-native时不滚动
我想在使用ScrollView(水平)时水平滚动的卡片中呈现react原生快照旋转木马,但react原生快照旋转木马的“旋转木马”不仅仅在android中滚动。 请在您的android手机中运行此expo零食,以重新创建问题react-native snap carousel在Android中放入ScrollView react-native时不滚动,react-native,react-native-flatlist,react-native-scrollview,react-native-snap-carousel,React Native,React Native Flatlist,React Native Scrollview,React Native Snap Carousel,我想在使用ScrollView(水平)时水平滚动的卡片中呈现react原生快照旋转木马,但react原生快照旋转木马的“旋转木马”不仅仅在android中滚动。 请在您的android手机中运行此expo零食,以重新创建问题 从“React”导入React; 导入{样式表、文本、视图、尺寸、SafeAreaView、TouchableHighlight、ScrollView、, TouchableOpacity,TouchableWithoutFeedback,Image,Linking,Pla
从“React”导入React;
导入{样式表、文本、视图、尺寸、SafeAreaView、TouchableHighlight、ScrollView、,
TouchableOpacity,TouchableWithoutFeedback,Image,Linking,Platform}来自“react native”;
从“react native snap Carousel”导入旋转木马,{Pagination};
从“react native elements”导入{Input,Button,Divider,Card,Overlay};
导出默认类Cart扩展React.Component{
状态={
数据:[
{title:'a',url:require(“./Light-Hover34x34.png”)},
{title:'b',url:require(“./Light-Hover34x34.png”)},
{title:'c',url:require(“./Light-Hover34x34.png”)},
{title:'d',url:require(“./Light-Hover34x34.png”)},
{title:'e',url:require(“./Light-Hover34x34.png”)},
],
动态幻灯片:0,
房间:[“一”、“二”、“三”]
}
_renderItem=({item,index})=>{
log(“活动幻灯片”,this.state.activeSlide)
const isActive=index==this.state.activeSlide;
返回(
Linking.openURL(item.url)}
风格={{
背景颜色:isActive?“#FFD845”:空,
宽度:60,
身高:60,
边界半径:60/2,
为内容辩护:“中心”,
对齐项目:“居中”,
}}>
);
};
render(){
返回(
{
this.state.room.map((r,i)=>{
返回(
用于分页的.setState({activeSlide:index}}//
/>
)
})
}
);
}
}
const styles=StyleSheet.create({
卡片循环标记:{
背景颜色:“黄色”,
//marginBottom:10,
//保证金余额:5%,
宽度:50,
身高:50,
边界半径:50/2,
边框颜色:“白色”,
},
卡德莱比格:{
边界半径:20,
边框底部宽度:0,
边框颜色:“白色”,
宽度:159,
高度:平台==“ios”?210:200,
阴影颜色:“000”,
阴影偏移:{
宽度:0,
身高:2,
},
阴影不透明度:0.25,
阴影半径:3.84,
标高:5,
边缘左:5,
marginRight:5,
玛金托普:10,
marginBottom:2
},
})
Carousel本身是一个scrollview,因此scrollview中的scrollview不起作用。hi@Ajith,感谢您的回复,但我尝试了所有给定的属性,如“nestedScrollEnabled”,或放置外部视图样式flex:1等,但没有解决问题。但我需要外卡才能滚动。但它在任何情况下都能正常工作IOS@Sagar你看到如何解决了吗?我面临着同样的问题,因为我还没有找到解决办法@Mahefa
import React from 'react';
import { StyleSheet, Text, View, Dimensions, SafeAreaView, TouchableHighlight, ScrollView,
TouchableOpacity, TouchableWithoutFeedback, Image, Linking, Platform } from 'react-native';
import Carousel, { Pagination } from 'react-native-snap-carousel';
import { Input, Button, Divider, Card, Overlay } from 'react-native-elements';
export default class Cart extends React.Component {
state = {
data: [
{ title: 'a', url: require("./Light-Hover34x34.png") },
{ title: 'b', url: require("./Light-Hover34x34.png") },
{ title: 'c', url: require("./Light-Hover34x34.png") },
{ title: 'd', url: require("./Light-Hover34x34.png") },
{ title: 'e', url: require("./Light-Hover34x34.png") },
],
activeSlide: 0,
room: ["one", "two", "three"]
}
_renderItem = ({ item, index }) => {
console.log("active slide", this.state.activeSlide)
const isActive = index === this.state.activeSlide;
return (
<TouchableHighlight
// onPress={() => Linking.openURL(item.url)}
style={{
backgroundColor: isActive ? '#FFD845' : null,
width: 60,
height: 60,
borderRadius: 60/2,
justifyContent: 'center',
alignItems: 'center',
}}>
<Image
source={item.url}
style={{ width: '50%', height: '40%' }}
/>
</TouchableHighlight>
);
};
render() {
return (
<View style={{alignItems: 'center', justifyContent: 'center', paddingVertical: 100}}>
<ScrollView horizontal={true}>
{
this.state.room.map((r, i) => {
return(
<View key={i}>
<TouchableWithoutFeedback>
<Card containerStyle={[styles.cardEleBig,]}>
<SafeAreaView style={{ height: 150 }}>
<Carousel
data={this.state.data}
renderItem={this._renderItem}
sliderWidth={120}
itemWidth={50}
onSnapToItem={index => this.setState({ activeSlide: index })} //for pagination
/>
</SafeAreaView>
</Card>
</TouchableWithoutFeedback>
</View>
)
})
}
</ScrollView>
</View>
);
}
}
const styles = StyleSheet.create({
cardCircleParking: {
backgroundColor: "yellow",
// marginBottom: 10,
// marginLeft: '5%',
width: 50,
height: 50,
borderRadius: 50/2,
borderColor: 'white',
},
cardEleBig: {
borderRadius: 20,
borderBottomWidth: 0,
borderColor: 'white',
width: 159,
height: Platform == "ios" ? 210 : 200,
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,
marginLeft: 5,
marginRight: 5,
marginTop: 10,
marginBottom: 2
},
})