【问题标题】:How to change the underline thickness in react native如何在本机反应中更改下划线粗细
【发布时间】:2019-12-23 09:36:12
【问题描述】:

我已经使用响应式本机几个星期了,但我一直卡在一个点上。我有一个文本,它带有下划线。但我需要使下划线的厚度更高,以便清晰可见。我试图找到一个解决方案,但没有得到任何解决方案。有人可以在这里帮助我吗?

我的代码如下。 :

<Text style={{textDecorationLine: 'underline'}}>Underlined Text</Text>

【问题讨论】:

  • AFAIK,你不能改变下划线的宽度,我最好的想法是使用 borderBottom 的视图来换行文本。您可能还必须在文本中提供 lineHeight 属性。

标签: javascript css react-native stylesheet


【解决方案1】:
<TextInput style={styles.textInput}/>


const styles = StyleSheet.create({ 
  textInput: {

    borderBottomColor: '#000', // Add this to specify bottom border color
    borderBottomWidth:  10   // Add this to specify bottom border thickness
}
});

【讨论】:

  • 我尝试在我的selected 样式中使用它,这样当我单击文本时,它会带有下划线。我想增加下划线的宽度,所以尝试使用borderBottom而不是下划线,但它对我不起作用。你能看看吗? snack.expo.io/@saachitech/da6280
【解决方案2】:

下划线文本

const styles = StyleSheet.create(
{
  Container:  
  {
    justifyContent: 'center',
    flex: 1,
  },
  TextStyle: 
  {
    textAlign: 'center',
    fontSize: 20,
    textDecorationLine: 'underline',
   }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-04
    • 1970-01-01
    • 1970-01-01
    • 2016-01-17
    • 1970-01-01
    • 2011-10-23
    • 2023-01-20
    • 2020-03-03
    相关资源
    最近更新 更多