我有带有 android:elevation="4dp"的 FrameLayout。这个高地的阴影指向下方。我想改变阴影的方向。
<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 Bottom Navigation Bar with drop shadow谢谢,Alexander Bilchuk。
解决方案:
您可以使用简单 View 及其背景在 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>
此外,如果使用这种方法,也不会出现兼容性问题。
关于android - 如何改变android高程阴影的方向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32677790/