Flutter 颤振:如何更改选项卡';s图标';幻灯片上的颜色,而不仅仅是点击?
因此,我设置了一个TabBarView,它的选项卡分别包含一个图标和一个文本。 当您通过滑动在选项卡之间切换时,文本的颜色似乎呈线性变化。您如何为图标实现同样的效果?我设法让它在轻触时切换颜色,但它在滑动时不遵守相同的规则Flutter 颤振:如何更改选项卡';s图标';幻灯片上的颜色,而不仅仅是点击?,flutter,tabs,tabbar,Flutter,Tabs,Tabbar,因此,我设置了一个TabBarView,它的选项卡分别包含一个图标和一个文本。 当您通过滑动在选项卡之间切换时,文本的颜色似乎呈线性变化。您如何为图标实现同样的效果?我设法让它在轻触时切换颜色,但它在滑动时不遵守相同的规则 我已尝试使用tabController.index==0等,但仍不起作用。使用轻触或滑动两者: child: new TabBar( indicatorColor: Colors.white, unsel
我已尝试使用
tabController.index==0
等,但仍不起作用。使用轻触
或滑动
两者:
child: new TabBar(
indicatorColor: Colors.white,
unselectedLabelColor: Colors.grey, // for unselected
labelColor: Colors.white, // for selected
indicatorWeight: 5.0,
tabs: [
new Tab(
text: 'Unpaid'.toUpperCase(),
),
new Tab(
text: 'Draft'.toUpperCase(),
),
new Tab(
text: 'All'.toUpperCase(),
),
],
),
),
),
body: new TabBarView(
children: [
new first.UnpaidInvoicePage(),
new second.PaidInvoicePage(),
new third.AllInvoicePage(),
],
),
请尝试以下代码:
- labelColor:Colors.black,//所选选项卡颜色(图标、文本)
- unselectedLabelColor:Colors.amber,//未选择的选项卡颜色(图标、文本)
import 'package:flutter/material.dart';
void main() {
runApp(TabBarDemo());
}
class TabBarDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(
unselectedLabelColor: Colors.amber, // UnSelected Tab Color
labelColor: Colors.black, // Selected Tab Color
tabs: [
Tab(icon: Icon(Icons.directions_car)),
Tab(icon: Icon(Icons.directions_transit)),
Tab(icon: Icon(Icons.directions_bike)),
],
),
title: Text('Tabs Demo'),
),
body: TabBarView(
children: [
Icon(Icons.directions_car),
Icon(Icons.directions_transit),
Icon(Icons.directions_bike),
],
),
),
),
);
}
}