在Android上更改高度时,react-native TextInput显示错误 [英] react-native TextInput displays wrong when changing height on Android

查看:69
本文介绍了在Android上更改高度时,react-native TextInput显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有以下样式的TextInput:

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)',
},

在iOS上,它似乎正确地没有足够的填充:

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

默认情况下,Android上具有大量填充:

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)',
}

在iOS上看起来不错:

Looks good on iOS:

但是Android搞砸了:

But Android messes up:

如何制作Android输入框,如倒数第二个iOS屏幕截图?谢谢.

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

推荐答案

Android在顶部和底部添加了一些默认填充,您可以通过在元素的样式中添加 paddingVertical:0 来重置它们.

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

这篇关于在Android上更改高度时,react-native TextInput显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆