Flutter中Text的使用
用于显示文本的组件。style属性控制
Style | TextStyle字体样式 |
---|---|
textAlign | 文本对齐 |
textDirection | 文字的方向 |
overflow | 文本尾部显示的样式 |
textScaleFactor | 文本大小比例 |
maxLines | 最大多少行 |
属性 | 作用 |
---|---|
color | 文字颜色 |
backgroundColor | 背景颜色 |
fontSize | 字体大小 |
fontWeight | 字体粗细 |
fontStyle | 字体样式 |
letterSpacing | 字母间距 |
wordSpacing | 每个字间距 |
decoration | 添加上划线下线,删除线 |
decorationColor | 划线颜色 |
class _MyHomePageState extends State<MyHomePage> {
@override Widget build(BuildContext context) {
return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: SizedBox( ////获得屏幕宽度 width: MediaQuery.of(context).size.width, //设置高德 height: 50, child: const Text("Hello,word11111111111111111111111111111111111111111111111111", ///文本对齐 textAlign: TextAlign.start, //最多多少行 maxLines: 1, //设置字体的样本 style: TextStyle(color: Colors.blue, //体的大小
fontSize: 15.0,
//添加上划线,下划线,删除线
decoration: TextDecoration.lineThrough,
//设置划线的颜色
decorationColor: Colors.red,
//字体的粗细
fontWeight:FontWeight.w200),
//文本结尾的演示
overflow: TextOverflow.ellipsis,
),
)
);
}
}