【问题标题】:Add elevation to BottomNavigationView将高程添加到 BottomNavigationView
【发布时间】:2018-06-21 21:38:32
【问题描述】:

这是我在 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",海拔会正确显示,但当我重新添加它时,它就会消失。

【问题讨论】:

  • 也许this post 会有所帮助。
  • 我遇到了,如果您看到我的代码,我实际上将背景设置为白色

标签: android android-support-library bottomnavigationview


【解决方案1】:

我认为问题不在于使用app:itemBackground 属性,而是您设置为itemBackground 的颜色。

如果我将我的app:itemBackground 颜色更改为白色,它可以正常工作,并且我可以显示底部导航视图的上方和底部的阴影。但是如果我使用我的原色(蓝色),我只能在我的 BottomNavigationView 的底部看到阴影。

我认为解决此问题的最简单方法是创建自己的阴影并将其设置在您的 BottomNavigationView 上方。这很简单。这个post 描述了你必须做什么。

如果遇到问题,请在下方留言。

希望这个回答能帮到你!!

祝你好运!

【讨论】:

  • 是的,这实际上是我最终做的,但我希望有人知道为什么设置会搞砸
猜你喜欢
  • 2017-04-07
  • 1970-01-01
  • 1970-01-01
  • 2020-12-04
  • 1970-01-01
  • 2023-03-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多