簡體   English   中英

Flutter: 選中時如何更改 label 樣式顏色

[英]Flutter: how to change label style color when it is selected

我想在選擇選項卡時將顏色更改為藍色,當未選擇選項卡時將顏色更改為灰色我已經這樣做了

TabBar(
  isScrollable: true,
  labelStyle: TextStyle(
  fontSize: 14.0,
  fontFamily: 'fontfamily',
  color: Colors.blue),
  unselectedLabelStyle:
  TextStyle(
  fontSize: 14.0, fontFamily: 'fontfamily'),
  tabs: myTabs,
  controller: _tabController,
            ),

你可以使用這個:

labelColor: Colors.blue,
unselectedLabelColor: Colors.grey,

您不必在 labelStyle 中指定文本顏色

  unselectedLabelColor: Colors.grey, //for unselected label//
  indicatorColor: Colors.grey, //indicates the label color when you click it//
  labelColor: Colors.blue, // shows the label color //

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM