零基础学Flutter之Widget基础组件Text

零基础学Flutter之Widget基础组件Text

  • Text组件结构
  • Text组件属性详讲
    • TextStyle

Text用于显示简单样式文本,它包含一些控制文本显示样式的一些属性

Text组件结构

Text(this.data, {
    Key key,
    this.style,
    this.textAlign,
    this.textDirection,
    this.locale,
    this.softWrap,
    this.overflow,
    this.textScaleFactor,
    this.maxLines,
    this.semanticsLabel,
  }) : assert(data != null),
       textSpan = null,
       super(key: key);

Text组件属性详讲

  • style:文本的样式属性
    • TextStyle

    	TextStyle({
    	    this.inherit = true,
    	    this.color,
    	    this.fontSize,
    	    this.fontWeight,
    	    this.fontStyle,
    	    this.letterSpacing,
    	    this.wordSpacing,
    	    this.textBaseline,
    	    this.height,
    	    this.locale,
    	    this.foreground,
    	    this.background,
    	    this.shadows,
    	    this.decoration,
    	    this.decorationColor,
    	    this.decorationStyle,
    	    this.debugLabel,
    	    String fontFamily,
    	    String package,
    	  }) : fontFamily = package == null ? fontFamily : 'packages/$package/$fontFamily',
    	       assert(inherit != null),
    	       assert(color == null || foreground == null, _kColorForegroundWarning);
    
    • color:字体颜色
    • fontSize:字体大小
    • fontWeight:字体宽度
    • fontStyle:字体样式(正常(FontStyle.normal)|倾斜(FontStyle.italic))
    • letterSpacing:字符间距
    • wordSpacing:单词间距
    • textBaseline:字体对齐方式(底部对齐(TextBaseline.alphabetic)|水平对齐(TextBaseline.ideographic))
    • height:字体高度
    • locale:字体国际化
    • foreground:字体前景
    • background:字体背景
    • shadows:字体阴影
    • decoration:字体装饰
    • decorationColor:字体装饰颜色
    • decorationStyle:字体装饰样式
    • fontFamily:字体粗细
    • package:字体包路径
  • textAlign:文本方向(左(TextAlign.left)|右(TextAlign.right)|中(TextAlign.center)|两端对齐(TextAlign.justify)|开始(TextAlign.start)|结束(TextAlign.end))
  • textDirection:文本对齐方式(文本从右到左(TextDirection.rtl)|文本从左到右(TextDirection.ltr))
  • locale:文本国际化
  • softWrap:文本是否能换行
  • overflow:文本溢出的处理方式(剪切(TextOverflow.clip)|隐藏(TextOverflow.fade)|省略号(TextOverflow.ellipsis))
  • textScaleFactor:文本字体缩放倍数
  • maxLines:文本最多能显示多少行

你可能感兴趣的:(跨平台开发)