Created
November 30, 2018 19:12
-
-
Save kashishgrover/b932095c774395680f2d30abd3f12f27 to your computer and use it in GitHub Desktop.
React Native Component Scaling Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const styles = StyleSheet.create({ | |
container: { | |
borderRadius: scale(4), | |
borderWidth: scale(0.5), | |
borderColor: '#d6d7da', | |
paddingHorizontal: scale(16), | |
}, | |
title: { | |
fontSize: scale(19), | |
fontWeight: 'bold', | |
}, | |
activeTitle: { | |
color: 'red', | |
}, | |
}); | |
// Do you use styled components? | |
const Button = styled.TouchableOpacity` | |
backgroundColor: #d6d7da; | |
paddingHorizontal: scale(14); | |
paddingVertical: scale(8); | |
`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, I am using this and it works great, but suppose I want to set predefined widths and heights to a Button, if I pass 200 as the input to the scale function, for example:- scalePx(200) BTW I am using styled Components, it appears too big on bigger devices and too small on smaller devices. Any suggestions please.