0

我有一个Scrollview我设置为水平的,但是当它没有完全显示组件时,它会剪切最后一个视图,或者如果子视图的宽度和高度更大,它不会显示所有视图,它会仍然剪切最后一个视图,我已经尝试更改contentContainerStyle它剪切的仍然,请问可能是什么问题

它在最后一个视图中剪切

以下是我的代码

   export default class Home extends Component {
    constructor(props) {
    const Width = Dimensions.get('window').width;
    super(props);
    this.state = {
        n: '0',
        no: 0,
        width: Width / 3
    };
 }
 return (
 <View style={styles.ox}>
 <View style={styles.firstColumn}>
  <Text style={styles.columnText}>
     Top Sold Items in your School{'\n'}
  </Text>
     <View style={styles.pictures}>
         <ScrollView contentContainerstyle={{flexGrow:1,
             flexDirection: 'row',}}  horizontal={true}
                     showsHorizontalScrollIndicator={false}
                     showsVerticalScrollIndicator={false}
                     automaticallyAdjustContentInsets={false}
                     directionalLockEnabled={true}
                     bounces={false}
                     scrollsToTop={false}>
             <View style={styles.miniPictures}>
         </View>
         <View style={styles.miniPictures}>
         </View>
             <View style={styles.miniPictures}>
             </View>
             <View style={styles.miniPictures}>
             </View>
             <View style={styles.miniPictures}>
             </View>
             <View style={styles.miniPictures}>
             </View>
         </ScrollView>
     </View>
 </View>
 </View>
    );
}
}
const dimensions = Dimensions.get('window');
const Height = (dimensions.height) / 5;
const Width = dimensions.width;
const styles = StyleSheet.create({
pictures: {
    flex: 1,
},
miniPictures: {
    height: 70,
    width: 70,
    marginRight: 10,
    borderTopRightRadius: 6,
    borderTopLeftRadius: 6,
    borderBottomLeftRadius: 6,
    borderBottomRightRadius: 6,
    backgroundColor: '#000',
    borderColor: '#d1d1d1'
},
columnText: {
    fontFamily: 'mont-medium',
    fontSize: 12,
    color: '#000'
},
firstColumn: {
    flexDirection: 'column',
    marginLeft: '6%',
    marginRight: '40%',
    paddingTop: 20,
    width: Width,
    height: 200
},
ox: {
    flexDirection: 'column',
    width: '100%',
    marginTop: 15,
},
headerCenter: {
    fontFamily: 'mont-bold',
    fontSize: 34,
    alignSelf: 'center',
    marginTop: 27,
    marginBottom: 14,
    letterSpacing: 0.7,
},
icons: {
    width: Width * (14.5/100),
    height: Width * (14.5/100),
    borderRadius: (Width* (14.5/100))/2,
    backgroundColor: '#F2C490',
    alignContent: 'center'
},
iconRow:{
    flex: 1,
    alignContent: 'center',
    justifyContent: 'space-between',
    marginLeft: 15,
    marginRight: 15,
    flexDirection: 'row'
}
});
4

1 回答 1

1

问题在:

firstColumn: {
    flexDirection: 'column',
    marginLeft: '6%',// Problem
    marginRight: '40%',
    paddingTop: 20,
    width: Width,// Problem
    height: 200
},

此样式有 marginLeft 6% 但仍然有宽度为 Width,您可以将宽度更改为Width - Width * 0.12或删除marginLeft

于 2018-08-18T11:02:47.777 回答