Reputation: 71
import {Dimensions} from 'react-native'
var {height, width} = Dimensions.get('window');
const styles = StyleSheet.create({
HeddingStyle:{
fontSize: (width*0.02)
}
})
But this is not working properly by using Dimensions
Upvotes: 0
Views: 86
Reputation: 1158
Use them separated, like this:
const SCREEN_WIDTH = Dimensions.get('window').width;
const SCREEN_HEIGHT = Dimensions.get('window').height;
Then on your styles you can do stuff like this:
inputContainer: {
width: SCREEN_WIDTH - 50,
}
Or in your case:
HeddingStyle:{
fontSize: SCREEN_WIDTH * 0.02,
}
Upvotes: 2