2014-05-04 81 views
4

如何从背景的左侧和右侧添加渐变阴影?向图层列表中添加渐变

以下layer-list只会从背景的左侧和右侧添加黑色边框,而不是渐变边框。

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 
    <item> 
     <shape android:shape="rectangle" > 
      <gradient 
       android:angle="0" 
       android:centerColor="#ffffff" 
       android:endColor="#000000" 
       android:startColor="#000000" /> 
     </shape> 
    </item> 
    <item 
     android:left="2dp" 
     android:right="2dp"> 
     <shape android:shape="rectangle" > 
      <solid android:color="@color/blue" /> 
     </shape> 
    </item> 
</layer-list> 

我试图从右侧添加黑色的阴影,离开的背景

+0

如果投下我的问题的人留下评论,它可能会更有帮助。 – user1940676

回答

2

我不是很确定你想要什么,渐变背景或渐变边框?这会给你一个渐变的黑色阴影背景

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle" > 
    <gradient 
     android:angle="0" 
     android:centerColor="#ffffff" 
     android:endColor="#000000" 
     android:startColor="#000000" /> 

</shape> 
+0

,你可以看到我已经有梯度 – user1940676

+0

你想你的背景是蓝色和渐变边框? – Ginsan

+0

是从背景的右侧和左侧 – user1940676