Flutter - Text Wigdet (1)

Screenshot_1589034997.png
import 'package:flutter/material.dart';

void main () {
  runApp(myApp()); // 主入口
}

class myApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      title:'Text Widget', 
      // 腳手架
      home:Scaffold( 
        body:Center(
          // Text Widgit
          child:Text(
          'hello xzp! 一起來學(xué)習(xí)這個Flutter吧', // 文本內(nèi)容
          textAlign: TextAlign.center, // 文本對齊方式
          maxLines: 1, // 文本最大展示行數(shù)
          overflow: TextOverflow.ellipsis, // 文本溢出處理方式
          style: TextStyle(
           fontSize: 20.0,  // 文本字體大小
           color: Color.fromARGB(255,255, 120, 30), // 文本顏色
           decoration: TextDecoration.underline, // 線條
           decorationStyle: TextDecorationStyle.dashed // 線條類型
          )),
        )
      )
    );
  }
}

Text Widget

是我學(xué)習(xí)的第一個組件,記錄一下吧

textAlign 文本的對齊方式
例:TextAlign.center 

center:   文本居中對齊
left:     文本左對齊
right :   文本右對齊
start:    以文本開始位置進行對齊,類似于左對齊
end:      以文本結(jié)尾處進行對齊,類似右對齊
maxLines 文本最大行數(shù)
例:maxLines: 1
overflow 文本溢出時的處理方式
例:TextOverflow.ellipsis
clip:      直接切斷,剩下的文字就沒有了。
ellipsis:  在后邊顯示省略號。
fade:      溢出的部分會進行一個漸變消失的效果。
style 文本屬性 (設(shè)置文本的顏色,字號,字體等屬性)
例:
    fontSize: 20.0,  // 文本字體大小
    color: Color.fromARGB(255,255, 120, 30), // 文本顏色
    decoration: TextDecoration.underline, // 線條
    decorationStyle: TextDecorationStyle.dashed // 線條類型
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容