可能重复:
如何在android中将阴影设置为View?
在我的Android应用程序中,我需要一个带圆角的布局,背景应该有一些透明度.为此,我使用这个xml,它工作正常:
customshape.xml:
<shape android:shape="rectangle">
<gradient android:startColor="#E2FFFFFF" android:endColor="#E2D0E3E5" android:angle="270"/>
<corners android:radius="10dp" />
</shape>
Run Code Online (Sandbox Code Playgroud)
style.xml:
<style name="LinearLayoutRoundCorners">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:background">@drawable/customshape</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我还需要在布局的右侧和底部有一个小阴影.我找不到办法做到这一点.我已经看到了一个黑客,你把另一个布局放在后面,使它看起来像一个阴影,但这对我不起作用,因为我的布局有透明度,所以看起来不会很好.如何在不使用图像作为布局背景的情况下在布局上获得漂亮的阴影效果?