【发布时间】:2015-12-21 17:35:07
【问题描述】:
我无法使用 Lollipop elevation 属性,因为我需要从 API 18 定位设备。
我需要在视图的右侧和左侧放置阴影。
这是我迄今为止尝试过的:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<item>
<shape >
<!-- set the shadow color here -->
<stroke
android:width="2dp"
android:color="#7000" />
<!-- setting the thickness of shadow (positive value will give shadow on that side) -->
<padding
android:bottom="0dp"
android:left="2dp"
android:right="2dp"
android:top="0dp" />
<corners android:radius="3dp" />
</shape>
</item>
<!-- Background -->
<item>
<shape>
<solid android:color="@color/salmon" />
<corners android:radius="3dp" />
</shape>
</item>
</layer-list>
我尝试在第一项中添加gradients,但它从左到右传播,这不是我想要的。有没有办法为每一侧隔离两个独特的渐变?
这就是我想要做的:
【问题讨论】:
-
如果答案对你有帮助,你应该接受它是正确的。
-
找到解决方案了吗?
标签: android xml user-interface gradient shadow