scrollview在ios中有效,但在android中不可用
import React from 'react';
import {
ScrollView,
StyleSheet,
Text,
View,
} from 'react-native';
export default class HomeScreen extends React.Component {
render() {
return (
<ScrollView style={css.outside} contentContainerStyle={css.contentContainer}>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
</ScrollView>
)
}
}
const css = StyleSheet.create({
outside :{
flex:1,
},
contentContainer: {
paddingTop: 30,
},
});
答案 0 :(得分:2)
您没有足够的内容。添加更多内容或尝试以下提供的内容,以确认它在android中工作正常。
import React from 'react';
import {
ScrollView,
StyleSheet,
Text,
View,
} from 'react-native';
export default class HomeScreen extends React.Component {
render() {
return (
<View style={{height: 150}}>
<ScrollView contentContainerStyle={css.contentContainer}>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
<Text>some text</Text>
</ScrollView>
</View>
)
}
}
const css = StyleSheet.create({
contentContainer: {
paddingTop: 30,
},
});
答案 1 :(得分:0)
在您的contentContainerStyle中尝试用flexGrow:1
代替flex:1
。