繁体   English   中英

在 Android 上更改高度时,react-native TextInput 显示错误

[英]react-native TextInput displays wrong when changing height on Android

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

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

在 iOS 上,它看起来好像没有足够的填充:

在此处输入图片说明

在 Android 上,默认情况下有巨大的填充:

在此处输入图片说明

没问题 - 我将设置左右填充和高度:

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

在 iOS 上看起来不错:

在此处输入图片说明

但是 Android 搞砸了:

在此处输入图片说明

如何制作像倒数第二个 iOS 屏幕截图一样的 Android 输入框? 谢谢。

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

对我来说,这是 Android 中的文本对齐问题。 textAlignVertical: 'top'添加到样式中为我修复了它。

使文本输入在 iOS 和 Android 上看起来相同。 给它一个特定的高度,这将覆盖 android 中的默认高度。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM