Reputation: 305
I'm following a tutorial to develop an android app using react native but there're some weird styling issues
this is my code:
import React, { Component } from 'react';
import {
AppRegistry,
ListView,
StyleSheet,
Text,
View
} from 'react-native';
class SimpleList extends Component {
constructor(props) {
super(props);
var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
dataSource: ds.cloneWithRows(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'])
};
}
_renderRow(rowData) {
return <Text style={styles.row}>{rowData}</Text>
}
render() {
return (<View style={styles.container}>
<ListView
dataSource={this.state.dataSource}
renderRow={(e) => this._renderRow(e)}/>
</View>);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF'
},
row: {
flex: 1,
fontSize: 24,
padding: 42,
borderWidth: 1,
borderColor: '#DDDDDD'
}
});
export default SimpleList;
my react native version is 0.30
Upvotes: 1
Views: 3833
Reputation: 305
I think I've figured it out
don't know why it works in the tutorial though
Upvotes: 1
Reputation: 79
for border u can just create function:
border: function(color) {
return {
borderColor: color,
borderWidth: 4
}
}
you can use like this:
<View style={this.border('green')}>
to adjust height, u can just use, marginTop or marginBottom
you can just use ScrollView like this(make sure import ScrollView)
<ScrollView>
<Text style={{fontSize:96}}>Scroll me plz</Text>
<Image source={require('./img/favicon.png')} />
</ScrollView>
Upvotes: 0