Flutter-Text文本组件

2022-04-27  本文已影响0人  阿博聊编程
配图来自网络,如侵必删

在开发中,文本是我们最常接触的控件。这篇博客来分享一下Flutter中的Text文本组件,我们展示的文本都可以用这个组件来展示,希望看文章的小伙伴有所帮助。

Text简单使用

Text("Hello Flutter",
      textAlign: TextAlign.center,
      style: TextStyle(fontWeight: FontWeight.bold)
)

这样我们就可以在界面当中显示一个文本,显示是Hello Flutter。下面我们来说说Text组件的属性:

设置文本颜色:

style: TextStyle(color: Colors.red))

设置文本大小:

style: TextStyle(fontSize: 20.0))

设置文本样式-加粗:

style: TextStyle(fontWeight: FontWeight.bold)

设置文本样式-斜体:

 style: TextStyle(fontStyle: FontStyle.italic))

设置文本位置:

textAlign: TextAlign.center,

TextAlign可选属性:centerendstartjustifyleftright

设置文本高度:

style: TextStyle(height:5.0))

设置文本最大行数:

maxLines: 1,

设置文本有下划线:

style: TextStyle(decoration: TextDecoration.underline))

设置文本有虚线类型下划线:

style: TextStyle(decorationStyle: TextDecorationStyle.dashed))

设置文字间隔:

style: TextStyle(letterSpacing: 5))

文本超过最大行数设置...

 overflow: TextOverflow.ellipsis,
上一篇 下一篇

猜你喜欢

热点阅读