【问题标题】:How to centralize text in textinput如何在文本输入中集中文本
【发布时间】:2015-07-12 18:34:22
【问题描述】:

一个简短的问题。
有没有办法在 react-native Textinput 中集中文本?

这是 jsx 中的标记:

<TextInput style={styles.input} placeholder="Your Account" />

在styles.input中,尝试添加textAlign:"center",不行。

与将 alignAlign 作为属性添加到标记中相同。 有人可以帮我一个忙吗?谢谢。

【问题讨论】:

  • @mplungjan 好像不是,我的是 textAlign:center in react native(just the same with html input text-align:center) ,他们的问题是多方面的问题行输入。

标签: javascript react-native


【解决方案1】:

您应该使用 inputText 道具将文本对齐到中心,如下所示

textAlign={'center'}

它看起来像

<TextInput style={styles.input} textAlign={'center'} placeholder="Your Account" />

【讨论】:

【解决方案2】:

这个错误已经存在了一段时间,但看起来很快就会合并修复:https://github.com/facebook/react-native/pull/772

【讨论】:

    【解决方案3】:

    android-only textAlignVertical 也可能是解决方案的必要组件。另见:How to align text input correctly in react native?

    【讨论】:

    • (虽然听起来你的目标可能是水平居中。)
    猜你喜欢
    • 2020-01-10
    • 1970-01-01
    • 2021-05-05
    • 1970-01-01
    • 1970-01-01
    • 2013-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多