![](https://img.haomeiwen.com/i25021128/912b01b75cd20829.png)
在开发中,文本是我们最常接触的控件。这篇博客来分享一下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可选属性:center
、end
、start
、justify
、left
、right
。
设置文本高度:
style: TextStyle(height:5.0))
设置文本最大行数:
maxLines: 1,
设置文本有下划线:
style: TextStyle(decoration: TextDecoration.underline))
设置文本有虚线类型下划线:
style: TextStyle(decorationStyle: TextDecorationStyle.dashed))
设置文字间隔:
style: TextStyle(letterSpacing: 5))
文本超过最大行数设置...
:
overflow: TextOverflow.ellipsis,
网友评论