TabBar(
controller: _tabController,
labelColor: const Color(0xFFF317CE),// 选中的的文字颜色
labelStyle: const TextStyle(
fontSize: 16,
//color: Color(0xFF333333)//如果不设置labelColor 此color不生效,所以可以去掉此行代码,因为颜色已经设置过了
),
unselectedLabelColor: Colors.white,//未选中时的文字颜色
unselectedLabelStyle: const TextStyle(
fontSize: 16,
//color: Color(0xFF999999)//如果不设置unselectedLabelColor 此color不生效,所以可以去掉此行代码,因为颜色已经设置过了
),
indicatorColor: const Color(0xFFF317CE),// 选中时下划线的颜色
indicatorWeight: 2,// 选中时下划线的粗细
indicatorPadding: const EdgeInsets.only(top: 9),
indicatorSize: TabBarIndicatorSize.label,
tabs: const [
Tab(
child: Text("推荐"),
),
Tab(
child: Text("关注"),
),
Tab(
child: Text("长视频"),
),
Tab(
child: Text("短视频"),
),
],
),
Flutter设置TabBar的文字颜色以及选中时的颜色
最新推荐文章于 2024-06-06 17:37:17 发布