是否有可能改变Y偏移的阴影方向?
现在我有以下布局
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container"
android:layout_width="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity" tools:ignore="MergeRootFrame" >
<TextView
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginBottom="200dp"
android:elevation="5dp"
android:translationZ="5dp"
android:background="@android:color/darker_gray"
android:layout_gravity="bottom"/>
<TextView
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginBottom="100dp"
android:elevation="4dp"
android:translationZ="5dp"
android:background="@android:color/holo_blue_dark"
android:layout_gravity="bottom"/>
<TextView
android:layout_width="match_parent"
android:layout_height="200dp"
android:elevation="3dp"
android:translationZ="5dp"
android:background="@android:color/holo_green_dark"
android:layout_gravity="bottom"/>
</FrameLayout>
在左边再现结果,但我喜欢在右边的图像上实现效果
任何人都可以指点我如何做到这一点?
最佳答案 在API 21中添加的View上的
setOutlineProvider
方法可能是有用的.从文档:
Sets the 07001 of the view, which generates the Outline that defines the shape of the shadow it casts, and enables outline clipping.
它允许定制形状,但我不能100%确定阴影方向可以改变.