如何在React Native中垂直对齐文本输入框中的文本?

5
我是React Native的新手。在文本输入框中,Android和iOS上的文本看起来不同。如何在文本输入框中垂直对齐文本?
我的代码:

import React from "react"
import { TextInput } from "react-native"


export default function Signup() {

    return (
        <TextInput
            style={{ backgroundColor: 'red', height: 30, textAlignVertical: 'top' }}
        />
    )
}

图片:

输入图像描述


尝试使用alignItems: 'top' - Ryan Millares
1个回答

7

textAlignVertical 仅适用于 Android。

看起来您的问题可以通过设置 paddingBottom: <number> 来解决,或者尝试将 lineHeight 设置为 fontSize


3
paddingBottom解决了我的问题。谢谢! - SoF

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接