如何设置BottomAppBar顶部边框为橙色且背景透明?
实现BottomAppBar透明背景+顶部橙色边框的方法
直接按下面的方式修改代码就能实现需求:
- 给外层
Container设置透明背景,同时把边框颜色改成橙色 - 给内部的
BottomAppBar设置backgroundColor: Colors.transparent,让它本身背景透明 - 可选:加上
elevation: 0去掉阴影,让透明效果更自然
完整代码示例:
Container( decoration: const BoxDecoration( border: Border(top: BorderSide(color: Colors.orange, width: 2)), color: Colors.transparent, // 容器背景透明 ), child: BottomAppBar( backgroundColor: Colors.transparent, // BottomAppBar背景透明 elevation: 0, // 移除阴影,可选 child: const Padding( padding: EdgeInsets.symmetric(vertical: 16), child: Text("你的底部导航内容"), ), ), )
原理很简单:外层Container负责显示顶部的橙色边框,同时自身背景透明;BottomAppBar本身的背景设为透明后,就能透出下方页面的内容,完美实现你要的效果。
内容的提问来源于stack exchange,提问作者chichi
相关产品推荐
相关产品推荐

