I tried setting elevation from xml and programmatically both. But nothing works.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
It only works if you set white as android:background in the BottomNavigationView.
This is my code and it's working:
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/white"
app:elevation="8dp"
app:itemIconTint="@color/bottom_color_state"
app:itemTextColor="@color/bottom_color_state"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.52"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_navigation_main" />
回答2:
I got the solution. You need to add background attribute along with elevation else it wont show the shadow.