带阴影的Android底部导航栏 [英] Android Bottom Navigation Bar with drop shadow

查看:471
本文介绍了带阴影的Android底部导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实现

解决方案

您可以使用简单的视图及其背景在底部栏上方绘制自己的阴影:

 <查看
android:layout_width = match_parent
android:layout_height = 4dp
android:layout_above = @ id / bottom_bar
android:background = @ drawable / shadow />

drawable / shadow.xml:

 < shape xmlns:android = http://schemas.android.com/apk/res/android> 
< gradient
android:startColor =#1F000000
android:endColor = @ android:color / transparent
android:angle = 90 />
< / shape>

此外,如果使用此方法,也不会出现兼容性问题。


I'm implementing Bottom Navigation Bar in Android app using Google's support design library v25.1.0. Is there any way to add drop shadow effect, same as current Android native Google Photos app?

解决方案

You can draw your own shadow just above the bottom bar using simple View and its background:

<View
    android:layout_width="match_parent"
    android:layout_height="4dp"
    android:layout_above="@id/bottom_bar"
    android:background="@drawable/shadow"/>

drawable/shadow.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#1F000000"
        android:endColor="@android:color/transparent"
        android:angle="90" />
</shape>

Also, there are no compatibility issues if use this approach.

这篇关于带阴影的Android底部导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆