我改变了 TextInput 的高度,但在 Android 上输入本身保持在中间。如何更改它以使文本从框顶部开始?
textInput: {
borderWidth: 1,
borderColor: "rgba(199,218,228,1)",
borderRadius: 8,
height: 312,
paddingTop: 8.21,
paddingBottom: 8.21,
paddingHorizontal: 16,
fontFamily: "FiraSans-Regular",
fontSize: 14,
},
最佳答案
textAlignVertical
应该可以帮助您,该组件的默认行为是将文本在输入中居中。
如果添加:
textAlignVertical: 'top'
根据您的风格,它应该将输入带到开头。该信息有点隐藏在 multiline
属性下的文档中:https://reactnative.dev/docs/textinput#multiline
multiline
If true, the text input can be multiple lines. The default value is false. It is important to note that this aligns the text to the top on iOS, and centers it on Android. Use with textAlignVertical set to top for the same behavior in both platforms.
关于reactjs - 如何自定义 React Native TextInput 的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65711515/