0

这是我的 xml 文件,它在线性布局周围添加边框我如何在此代码中添加渐变颜色效果代码?我想用渐变颜色替换这个颜色#C0C0C0

下面是我的代码

  <?xml version="1.0" encoding="utf-8"?>
  <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item> 
     <shape android:shape="rectangle">
     <solid android:color="#000000" /> 
     </shape>
  </item>   
  <item 
      android:left="1dp" 
      android:right="1dp"  
       android:top="2dp" 
      android:bottom="2dp"    >  
 <shape android:shape="rectangle"> 
 <solid android:color="#C0C0C0" />
 </shape>
 </item>    
 </layer-list> 

我想在我的边框 .xml 文件中添加此代码我如何合并?

 <shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="rectangle">

 <gradient
  android:startColor="#fefdfe"
  android:endColor="#e8e3ec"
  android:angle="90" />

 </shape>
4

3 回答 3

1

用渐变填充布局:

<?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:startColor="#4fc939"
            android:centerColor="#0c87c5"
            android:endColor="#b4ec51"
            android:angle="180" />
    </shape>
</item>

于 2016-05-31T14:38:10.803 回答
0

尝试这个:-

 <shape android:shape="rectangle">
        <gradient
                android:startColor="#5a5a5a88"
                android:endColor="#14141488"
                android:angle="270" android:centerX="0.25"/>

   </shape>
于 2013-07-23T07:45:31.790 回答
0

只需更换

<shape android:shape="rectangle"> 
    <solid android:color="#C0C0C0" />
</shape>

用你的渐变形状。

于 2013-07-23T07:21:50.797 回答