reactjs - 如何自定义 React Native TextInput 的高度?

标签 reactjs react-native

我改变了 TextInput 的高度,但在 Android 上输入本身保持在中间。如何更改它以使文本从框顶部开始? This is how it looks on 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/

相关文章:

javascript - React - 单击不是其子组件的组件时呈现组件

javascript - 年份未定义

javascript - 如何在 react-native 中将文本复制到剪贴板?

react native 推送通知未定义

ios - 我可以使用命令重新加载我的 React Native 应用程序吗?

javascript - react native "Attempted to assign to readonly property"

javascript - 有什么方法可以更改 Electron 文件对话框的标题和保存类型吗?

javascript - 用于获取、喜欢和不喜欢帖子的 Redux reducer

javascript - 在 React Native 中为单个 Picker.Item 设置样式

javascript - React 中的搜索组件未显示在应用程序组件上