user2589245
user2589245

Reputation: 721

how to add gradient effect in layout border xml file

this is my xml file which add border around linear layout how do i add gradient color effect code inthis code? i want replace this color #C0C0C0 with gradiend color

below is my code

  <?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> 

i want to add this code in my border .xml file how i merge??

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

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

 </shape>

Upvotes: 0

Views: 2931

Answers (3)

Alon Kogan
Alon Kogan

Reputation: 3418

fill layout with gradient:

<?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>

Upvotes: 1

Suresh Sharma
Suresh Sharma

Reputation: 1844

Try this:-

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

   </shape>

Upvotes: 0

mindeh
mindeh

Reputation: 1818

Just replace

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

with your gradient shape.

Upvotes: 0

Related Questions