当前位置:   article > 正文

Flutter 学习之路 Text 文本组件_flutter text 靠右对齐

flutter text 靠右对齐

一、Flutter Text文本组件介绍:

    文本组件(Text)负责显示文本和定义显示样式,它包含控制文本显示样式属性

二、构造方法中属性说明:

  1. const Text(
  2.     this.data, {  // 文字内容
  3.     Key key,
  4.     this.style, // 字体的样式设置
  5.     this.strutStyle,
  6.     this.textAlign, //文本对齐方式(center居中,left左对齐,right右对齐,justfy两端对齐)
  7.     this.textDirection,//文本方向(ltr从左至右,rtl从右至左)
  8.     this.locale, // 用于选择区域特定字形的语言环境
  9.     this.softWrap, // 是否需要换行
  10.     this.overflow, //文字超出屏幕之后的处理方式(clip裁剪,fade渐隐,ellipsis省略号)
  11.     this.textScaleFactor, //字体显示倍率
  12.     this.maxLines,  // 文字显示最大行数
  13.     this.semanticsLabel, // 图像的语义描述,用于向Andoid上的TalkBack和iOS上的VoiceOver提供图像描述
  14.     this.textWidthBasis,
  15.     this.textHeightBehavior,
  16.   })

属性style中 TestStyle 的参数

  1. const TextStyle({
  2.     this.inherit = true,
  3.     this.color,  // 颜色
  4.     this.backgroundColor, // 背景色
  5.     this.fontSize,    // 字体大小
  6.     this.fontWeight,  // 字体粗细  
  7.     this.fontStyle,    // 文字样式(italic 斜体,normal 正常体)
  8.     this.letterSpacing, // 字母间隙   
  9.     this.wordSpacing,    // 单词间距
  10.     this.textBaseline,    // 对齐文本的水平线
  11.     this.height,    // 高度
  12.     this.locale,    // 用于选择区域特定字形的语言环境
  13.     this.foreground,    // 文本的前景色
  14.     this.background,    // 文本背景色
  15.     this.shadows,
  16.     this.fontFeatures,    
  17.     this.decoration,    // 文本装饰
  18.     this.decorationColor, // 文本装饰颜色   
  19.     this.decorationStyle, // 文本装饰样式   
  20.     this.decorationThickness,
  21.     this.debugLabel,
  22.     String fontFamily,
  23.     List fontFamilyFallback,
  24.     String package,
  25.   })

代码演示:

  1. import 'package:flutter/material.dart';
  2. class TextPage extends StatefulWidget {
  3.   TextPage({Key key}) : super(key: key);
  4.   @override
  5.   _TextPageState createState() => _TextPageState();
  6. }
  7. class _TextPageState extends State {
  8.   @override
  9.   Widget build(BuildContext context) {
  10.     return Scaffold(
  11.       appBar: AppBar(
  12.         title: Text("56zhiyi.com Flutter Text"),
  13.       ),
  14.       body: Container(
  15.         alignment: Alignment.center,
  16.         padding: EdgeInsets.only(top: 20),
  17.         child: Column(
  18.           crossAxisAlignment: CrossAxisAlignment.center,
  19.           children: [
  20.             Text(
  21.               "下划线演示",
  22.               style: TextStyle(decoration: TextDecoration.underline),
  23.             ),
  24.             Text(
  25.               "中划线演示",
  26.               style: TextStyle(decoration: TextDecoration.lineThrough),
  27.             ),
  28.             Text(
  29.               "综合演示",
  30.               textAlign: TextAlign.right,
  31.               style: TextStyle(
  32.                   fontSize: 14.0,
  33.                   color: Colors.red,
  34.                   fontWeight: FontWeight.w800,
  35.                   fontStyle: FontStyle.italic,
  36.                   decoration: TextDecoration.lineThrough,
  37.                   decorationColor: Colors.white,
  38.                   decorationStyle: TextDecorationStyle.dashed,
  39.                   letterSpacing: 4.0),
  40.               overflow: TextOverflow.ellipsis,
  41.               maxLines: 1,
  42.               textScaleFactor: 2,
  43.             ),
  44.           ],
  45.         ),
  46.       ),
  47.     );
  48.   }
  49. }

效果图

text.png

 

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/289726
推荐阅读
相关标签
  

闽ICP备14008679号