Android半透明背景与阴影 [英] Android translucent background with shadow
本文介绍了Android半透明背景与阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试用半透明的XML创建背景可绘制资源,但是要有一个坚实的阴影.
I'm trying to create a background drawable resource in XML that is translucent, but with a solid shadow.
这是我到目前为止所拥有的:
This is what I have so far:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle" >
<padding
android:top="-2dp"
android:left="-2dp"
android:right="2dp"
android:bottom="2dp"
/>
<gradient
android:startColor="@android:color/transparent"
android:centerColor="#33333333"
android:endColor="#aa666666"
android:angle="90"/>
</shape>
</item>
<!-- Background -->
<item>
<shape>
<solid android:color="#99000000" />
<corners android:radius="3dp" />
</shape>
</item>
</layer-list>
我使用渐变形状作为背景,但不幸的是,这种形状模糊了背景形状的半透明性.我只想在背景形状的右侧和底部绘制渐变2px,可以吗?
I'm using a gradient shape as the background, which unfortunately obscures the translucency of the background shape. I only want to draw the gradient 2px to the right and bottom of the background shape, is that possible?
推荐答案
尝试一下...
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:right ="2dp"
android:bottom ="2dp">
<shape android:shape="rectangle" >
<padding
android:left="2dp"
android:top="2dp"
/>
<corners android:radius="3dp" />
<gradient
android:startColor="@android:color/transparent"
android:centerColor="#33333333"
android:endColor="#aa666666"
android:angle="90"/>
</shape>
</item>
<!-- Background -->
<item>
<shape android:shape="rectangle" >
<solid android:color="#99000000" />
<corners android:radius="3dp" />
</shape>
</item>
</layer-list>
这篇关于Android半透明背景与阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文