Flutter text設置行間距【轉】


通過設置 StrutStyle 的 leading , 然后利用 Transform 做計算翻方向位置偏移,因為 leading 是上下均衡的,所以計算后就可以得到我們所需要的行間距大小。 (雖然無法保證一定 100%像素准確,你是否還知道其他方法?)

Transform.translate(
            offset: Offset(0,   1 / 2),   //1為 StrutStyle 的 leading的值
            child:Text(
            "1.xxxxxxxxxxxxxxxxxxx\n2.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n3.xxxxxxxxxxxxxxxxxxx\n4.xxxxxxxxxxxxxxxxxx",
            style: TextStyle(color: Color.fromRGBO(51, 51, 51, 1),fontSize: HspSize.setRpx(28),),
             strutStyle: StrutStyle(forceStrutHeight: true, height:1, leading: 1),
                        ),
)

來源:https://blog.csdn.net/qq_42944436/article/details/107914775


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM