android - 将高程添加到 BottomNavigationView
问题描述
这是我在 XML 中的底部导航栏的样子:
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@android:color/white"
app:itemBackground="@color/primary"
app:elevation="8dp"
app:menu="@menu/main_activity_bottom_nav"/>
如果我删除app:itemBackground="@color/primary"
,海拔显示正确,但我添加回来的那一刻,它消失了。
解决方案
我认为问题不在于使用app:itemBackground
属性,而在于您设置为 itemBackground 的颜色。
如果我将app:itemBackground
颜色更改为白色,它可以正常工作,并且可以显示底部导航视图的上方和底部的阴影。但是如果我使用我的原色(蓝色),我只能在我的 BottomNavigationView 的底部看到阴影。
我认为解决此问题的最简单方法是创建自己的阴影并将其设置在您的 BottomNavigationView 上方。这很简单。这篇文章描述了你必须做什么。
如果您遇到一些问题,请在下面发表评论。
我希望这个答案可以帮助你!
祝你好运!!
推荐阅读
- android - 更改按钮中的文本时,按钮正在更改 GridLayout 中的位置
- java - JAVA:将枚举集转换为由列表和引号分隔的字符串
- javascript - 如何遍历道具并增加道具内的值?
- python-3.x - 无法从链表中删除除第一个节点外的节点
- java - 安装eclipse:创建java虚拟机失败
- docker - Docker Compose 在 Windows 机器上找不到入口点
- c# - 如何找到两个或多个对象的中心位置?
- windows - 程序是否可以在没有 API 或 SDK 的情况下以编程方式与其他程序交互
- node.js - 为什么我的回调函数接收到不正确的参数值?
- arrays - 将标准输出块解析为 bash 或 ruby 中的数组