2

当我启动我的应用程序时,我的 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>

我能做些什么?

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

4

2 回答 2

2

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

于 2017-08-26T20:42:59.753 回答
1

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

如果要添加将从顶部显示的阴影,则BottomNavigationView需要手动绘制。

于 2017-08-26T20:55:40.317 回答