Flutter BottomNavigationBar无法应用背景图像-颤振
BottomNavigationBar在有超过3个BottomNavigationBarItem时不应用背景图像。它显示白色背景,而不是应用的图像。请检查代码,如果代码中有遗漏,请告诉我Flutter BottomNavigationBar无法应用背景图像-颤振,flutter,dart,background-image,flutter-bottomnavigation,Flutter,Dart,Background Image,Flutter Bottomnavigation,BottomNavigationBar在有超过3个BottomNavigationBarItem时不应用背景图像。它显示白色背景,而不是应用的图像。请检查代码,如果代码中有遗漏,请告诉我 bottomNavigationBar: Container( decoration: BoxDecoration( image: DecorationImage(image: AssetImage('assets/images/tabbar_backgro
bottomNavigationBar: Container(
decoration: BoxDecoration(
image: DecorationImage(image: AssetImage('assets/images/tabbar_background.png'), fit: BoxFit.fill),
),
child: BottomNavigationBar(
backgroundColor: Colors.transparent,
elevation: 0,
items: [
BottomNavigationBarItem(icon: Image.asset("assets/images/eplay.png"), title: Text('title')),
BottomNavigationBarItem(icon: Image.asset("assets/images/games.png"), title: Text('title')),
BottomNavigationBarItem(icon: Image.asset("assets/images/retail-location.png"), title: Text('title')),
BottomNavigationBarItem(icon: Image.asset("assets/images/scan.png"), title: Text('title')),
/* BottomNavigationBarItem(icon: Image.asset("assets/images/scan.png"), title: Text('title')),
*/
],
),
添加
type:BottomNavigationBarType.fixed
作为BottomNavigationBar
的属性
我以您的代码为例添加了一个演示:
bottomNavigationBar:容器(
装饰:盒子装饰(
图像:装饰图像(图像:AssetImage('assets/images/tabbar_background.png'),fit:BoxFit.fill),
),
子项:底部导航栏(
背景颜色:颜色。透明,
类型:BottomNavigationBarType.fixed,//新行
海拔:0,
项目:[
BottomNavigationBarItem(图标:Image.asset(“assets/images/eplay.png”),标题:Text(“title”),
BottomNavigationBarItem(图标:Image.asset(“assets/images/games.png”),标题:Text(“title”),
BottomNavigationBarItem(图标:Image.asset(“assets/images/retail location.png”),标题:Text(“title”),
BottomNavigationBarItem(图标:Image.asset(“assets/images/scan.png”),标题:Text(“title”),
/*BottomNavigationBarItem(图标:Image.asset(“assets/images/scan.png”),标题:Text(“title”),
*/
],
),
背景图像正在工作。但是我需要类型:BottomNavigationBarType.shifting根据我的要求。有帮助吗?背景图像没有出现。我看到白色背景。因此根据文档如果[type]为空,那么当有两个或三个[items],[BottomNavigationBarType.shifting]时使用[BottomNavigationBarType.fixed]否则。
因此我不能使用BottomNavigationBarType.Shift与背景图像?如果您使用的是Shift
类型,则必须给出selectedItemColor
和unselectedItemColor
,这可能是出现白色屏幕的原因。