阴影导航选项卡栏顶部的高度

Elevation on Top of a Navigation Tab Bar for Shadow

我正在尝试使用 Material 设计中的 Elevation 在导航选项卡栏上创建阴影。

遵循我了解到我需要的其他指南:

我能够使用适配器在我的回收站视图的元素中执行此操作,但我无法直接在我的 xml activity.

上使用它
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/neah_screen_bg_white"
tools:context="at.next.neah.screens.main.activitys.MainActivity">


<android.support.v4.view.ViewPager
android:id="@+id/main_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:layout_constraintBottom_toTopOf="@+id/main_navigation_bar_space"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<android.support.v4.widget.Space
android:id="@+id/main_navigation_bar_space"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="4dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="@id/main_navigation_bar"/>

<android.support.constraint.ConstraintLayout
android:id="@+id/main_navigation_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingTop="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">


<at.next.neah.customView.SlidingTab.SlidingTabLayout
android:id="@+id/main_tabs"
android:layout_width="0dp"
android:layout_height="48dp"
android:elevation="8dp"
android:background="@color/neah_screen_bg_grey_dark"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:tabGravity="fill" />

<ImageView
android:id="@+id/main_icon_home"
android:elevation="8dp"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="11dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="11dp"
android:contentDescription="@string/icon_contentDescription"
app:layout_constraintBottom_toBottomOf="@+id/main_tabs"
app:layout_constraintEnd_toStartOf="@+id/main_icon_network"
app:layout_constraintStart_toStartOf="@+id/main_tabs"
app:layout_constraintTop_toTopOf="@+id/main_tabs"
app:srcCompat="@mipmap/img_splash_logo" />

<ImageView
android:id="@+id/main_icon_network"
android:elevation="8dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:contentDescription="@string/icon_contentDescription"
app:layout_constraintBottom_toBottomOf="@+id/main_tabs"
app:layout_constraintEnd_toStartOf="@+id/main_icon_chat"
app:layout_constraintStart_toEndOf="@id/main_icon_home"
app:layout_constraintTop_toTopOf="@+id/main_tabs"
app:srcCompat="@drawable/ic_network_grey_28dp" />

<ImageView
android:id="@+id/main_icon_chat"
android:elevation="8dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:contentDescription="@string/icon_contentDescription"
app:layout_constraintBottom_toBottomOf="@+id/main_tabs"
app:layout_constraintEnd_toStartOf="@+id/main_icon_notification"
app:layout_constraintStart_toEndOf="@id/main_icon_network"
app:layout_constraintTop_toTopOf="@+id/main_tabs"
app:srcCompat="@drawable/ic_chat_grey_35dp" />

<ImageView
android:id="@+id/main_icon_notification"
android:elevation="8dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:contentDescription="@string/icon_contentDescription"
app:layout_constraintBottom_toBottomOf="@+id/main_tabs"
app:layout_constraintEnd_toStartOf="@+id/main_icon_profile"
app:layout_constraintStart_toEndOf="@id/main_icon_chat"
app:layout_constraintTop_toTopOf="@+id/main_tabs"
app:srcCompat="@drawable/ic_notifications_grey_28dp" />

<ImageView
android:id="@+id/main_icon_profile"
android:elevation="8dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:contentDescription="@string/icon_contentDescription"
app:layout_constraintBottom_toBottomOf="@+id/main_tabs"
app:layout_constraintEnd_toEndOf="@+id/main_tabs"
app:layout_constraintStart_toEndOf="@id/main_icon_notification"
app:layout_constraintTop_toTopOf="@+id/main_tabs"
app:srcCompat="@drawable/ic_person_grey_28dp" />

</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>

我有一个碎片容器 一个 space 元素,用于将片段放在阴影后面 导航栏填充的一种约束布局 导航栏的元素。

阴影应该在灰色背景之上,蓝色选区之下

直接放代码

android:elevation="8dp"
android:background="@color/neah_screen_bg_grey_dark"

在约束布局内并起作用。