如何改变机器人高程阴影的方向



我有框架布局与android:海拔="4dp"。这一高地的阴影向下投射。我想把阴影的方向改为向上

<FrameLayout
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:elevation="10dp"
    android:layout_marginBottom="100dp"
    android:background="@color/ColorPrimary"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true">
</FrameLayout>

我认为这种方法是最好的解决方案:Android底部导航栏与阴影谢谢,Alexander Bilchuk。

解决方案:

你可以使用简单的view和它的背景在视图的上方绘制你自己的阴影:

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

可拉的/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>

视图下拉阴影可以被转换,或者在x和y方向上缩放,通过改变视图的轮廓提供程序,如本文所述。

在我看来,你不能自己改变阴影。在android材质设计中,阴影是由你提升元素的数量自动决定的。

根据这个问题https://graphicdesign.stackexchange.com/questions/80644/where-are-the-light-sources-located-in-material-design光源是

45度高度90度角

你真的不应该使用不同的阴影,因为它会破坏材料设计的整体一致性。那么你唯一要做的就是提升你的元素。也许你应该重新阅读材料设计指南:https://material.io/guidelines/material-design/environment.html#environment-light-shadow

最新更新