【问题标题】:Elevation not working on BottomNavigationView海拔在底部导航视图上不起作用
【发布时间】:2023-03-17 19:41:01
【问题描述】:

我的 BottomNavigationView 上的海拔没有工作,当我启动我的应用程序时,所有其他 UI 组件都获得了它们的特定海拔,但 BottomNavigationView。

这是 XML:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <FrameLayout
        android:id="@+id/main_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/bottom_navigation"
        android:layout_alignParentTop="true">
    </FrameLayout>

    <android.support.design.widget.BottomNavigationView
        android:elevation="8dp"
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:itemBackground="@color/white"
        app:itemIconTint="@drawable/nav_item_color_state"
        app:itemTextColor="@drawable/nav_item_color_state"
        android:layout_alignParentBottom="true"/>

</RelativeLayout>

我能做什么?

注意:没有颜色是透明的。

【问题讨论】:

  • android:background属性添加到BottomNavigationView,看看是否有效
  • 还是没有变化
  • 有同样的问题。你找到解决方案了吗? @Ale4303
  • 不,还没有。还在寻找:(

标签: android android-elevation bottomnavigationview


【解决方案1】:

您应该使用命名空间xmlns:app="http://schemas.android.com/apk/res-auto" 并使用app:elevation = "8dp" 而不是android:elevation="8dp"

【讨论】:

    【解决方案2】:

    阴影被向下绘制(从视图底部),您可以看到应用了android:elevation="8dp" 如果您尝试显示Snackbar,您将无法看到它。

    如果您想添加从BottomNavigationView 顶部显示的阴影,您需要将其绘制为manually

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-12
      • 1970-01-01
      • 2018-03-05
      • 2021-10-20
      • 2021-08-18
      • 1970-01-01
      • 2020-05-13
      • 1970-01-01
      相关资源
      最近更新 更多