Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android shape border with gradient and middle transparent

I need to create a round corner border, where border with gradient.enter link description here is working.But My page is using a image as background which is also with gradient. I need to show background image from middle of the filed. I want to create just like below image:enter image description here

like image 766
Suman Avatar asked Oct 29 '16 19:10

Suman


1 Answers

round_background.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
<stroke
    android:width="4dp"
    android:color="@color/transparent" />
    <gradient
        android:startColor="#374533"
        android:centerColor="#432727"
        android:endColor="#222430"
        android:angle="135"/>
    <corners android:radius="10dp" />
</shape>

round_border.xml

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

<gradient
    android:startColor="#efe301"
    android:centerColor="#7dc17b"
    android:endColor="#01dae6"
    android:angle="180"/>
<corners android:radius="10dp" />

result_drawable.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

  <item android:drawable="@drawable/round_border"/>
  <item android:drawable="@drawable/round_background" />

</layer-list>

Here, you can set android:width="4dp" in round_background.xml to set size of your border. use result result_drawable.xml where you want.. Enjoy. :}

like image 64
jainish champaneria Avatar answered Nov 21 '22 07:11

jainish champaneria