Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Native's padding difference for Android vs iOS

The problem when I use padding style it's a difference on Android - iOS

<Content  style={{padding: '7%'}}>

how can I take it in the same style

the image

like image 505
boy_v Avatar asked Nov 21 '25 05:11

boy_v


1 Answers

React native is unitless. It means that the value of 7% is not a valid value in this case. you should use a static value like 7 or 20 or you can use the Dimensions.get('window').width to get the width of page and use this to set some attributes. your code will be like this:

let windowWidth = Dimensions.get('window').width

<Content  style={{padding: windowWidth*7/100}}> // equal to 7%
like image 91
Vahid Boreiri Avatar answered Nov 22 '25 18:11

Vahid Boreiri