react-native TextInput displays wrong when changing height on Android

痴心易碎 提交于 2020-06-09 12:14:13

问题


I have a TextInput with the following style:

amountInput: {
  flex: 1,
  backgroundColor: 'rgba(255, 255, 255, 0.1)',
  color: 'rgba(255, 255, 255, 0.9)',
},

On iOS it correctly looks like it doesn't have enough padding:

On Android is has enormous padding by default:

Not a problem - I'll set a right and left padding, and a height:

amountInput: {
  flex: 1,
  backgroundColor: 'rgba(255, 255, 255, 0.1)',
  height: 30,
  paddingRight: 5,
  paddingLeft: 5,
  color: 'rgba(255, 255, 255, 0.9)',
}

Looks good on iOS:

But Android messes up:

How can I make an Android input box like the penultimate iOS screenshot? Thanks.


回答1:


Android adds some default padding on top and bottom, you can reset them by adding paddingVertical: 0 to your element' style.



来源:https://stackoverflow.com/questions/37878613/react-native-textinput-displays-wrong-when-changing-height-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!