【问题标题】:Shadow at the top of Bottom App Bar底部应用栏顶部的阴影
【发布时间】:2018-12-27 09:38:11
【问题描述】:

我正在使用 Material Design Components 中的新 Bottom App Bar。我正在尝试在底部应用栏的顶部提供阴影,就像 Google Tasks 应用中的一样,如下所示。

我尝试过同时使用android:elevationapp:elevation 属性。请帮忙。

【问题讨论】:

  • 这是您的解决方案:stackoverflow.com/a/32397225/4255978
  • 在顶部显示阴影违反了材质准则。您不能在正负 Y 方向上都有阴影。 (“添加新任务”按钮和操作按钮的阴影方向相反)。你应该避免它。
  • @RahulKumar 问题中显示的此屏幕截图来自 Google 的 Tasks 应用程序。
  • @Mehul 他们以打破自己的准则而闻名。那我能说什么呢。
  • @RahulKumar 但是,如果您要使用具有白色背景的底部应用栏,那么您将不得不添加阴影,因为它无法识别。我试过了。

标签: android android-layout mdc-components


【解决方案1】:

我最终使用了这个solution


第 1 步 在drawable文件夹中创建shape_drawable.xml文件,如下图:

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

第 2 步 创建一个View,将shape_drawable.xml 设置为其背景,然后将视图放置在BottomAppBar 的正上方。

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

【讨论】:

    【解决方案2】:

    根据this commit,在 Android 材料组件 1.1.0 (alpha) 版本中修复了高程。

    编辑

    对于那些想知道的人,这是添加新依赖项的方式:

    dependencies {
        // ...
        implementation 'com.google.android.material:material:1.1.0-alpha02'
        // ...
    }
    

    更多关于入门的信息可以在here找到,关于发布的信息可以在here找到。

    干杯!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多