【问题标题】:React Native TextInput ellipses truncationReact Native TextInput 省略截断
【发布时间】:2020-01-22 01:25:19
【问题描述】:

我已经看到很多与如何为 TextInput 组件的溢出文本添加省略号相关的问题,但无论我向 TextInput 文本的样式添加什么,似乎总是将省略号添加到溢出文本。已要求隐藏溢出的文本:

<TextInput
    placeholder='0%'
    value={this.state.cbc}
    onChangeText={(text) => this.setState({ cbc: text })}
    style={styles.compoundInput}
>

.
.
.
compoundInput: {
        borderWidth: 1,
        borderRadius: 10,
        height: 40,
        padding: 5,
        minWidth: 55,
        maxWidth: 85,
        marginLeft: 10,
        fontFamily: 'OpenSans',
        fontSize: 14,
        justifyContent: 'center',
        alignItems: 'center',
    }
.
.
.

有没有办法确保溢出的文本被隐藏?

【问题讨论】:

    标签: css react-native


    【解决方案1】:
    const styles = StyleSheet.create({
        gridItem:{
            flex:1,  //it can get as much space as it can get
            margin:15,
            height:150,
            borderRadius:10,
            elevation: 5, 
            overflow:Platform.OS === 'android' && Platform.Version >=21 ? 'hidden'
             : 'visible'
    
        }
    

    我认为你可以使用

    溢出:'隐藏'

    在样式组件中。或者我想您也可以使用 Platform API 在特定平台上查看更多内容。

    https://facebook.github.io/react-native/docs/platform-specific-code

    【讨论】:

      猜你喜欢
      • 2023-01-19
      • 1970-01-01
      • 1970-01-01
      • 2020-09-30
      • 2021-08-25
      • 2011-09-17
      • 2020-09-05
      • 2021-10-24
      相关资源
      最近更新 更多