'React Native responsive margin and padding
I would like to know if setting paddings and margins to a responsive value is the right way to do things in React Native.
For instance, let's say that I have a Button component. My button component has a padding and the text inside should be responsive. I'm already handling text as responsive with my custom function (code below), and works just fine, the problem here is that if a person tries the app in a very small devide, the text inside the button will look cool, but the padding will be way too much compared to the text size, since I'm setting a fixed value. So, is it right to use the same function that calculates the text size to calculate my padding too?
My responsive size calculate function:
const scale = width / 375
export const normalize = (size: number): number => {
const newSize = size * scale
if (Platform.OS === 'ios') {
return Math.round(PixelRatio.roundToNearestPixel(newSize))
} else {
return Math.round(PixelRatio.roundToNearestPixel(newSize)) - 2
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
