Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add gradient in edit text border in android

I want to add gradient only to the border of my editText , I can add gradient but it takes the entire background . How can I apply gradient only to the border , and the rest should be transparent?

enter image description here

like image 950
mSapps Avatar asked Dec 06 '25 23:12

mSapps


1 Answers

This one does the trick :)

<?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="45"
                android:endColor="#0256FC"
                android:centerColor="#0256FC"
                android:startColor="#FE00B1" />
            <corners android:radius="4dp" />
            <padding
                android:bottom="1dp"
                android:left="1dp"
                android:right="1dp"
                android:top="1dp" />
            <size
                android:width="162dp"
                android:height="44dp" />
        </shape>
    </item>
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/colorWhite" />
            <corners android:radius="4dp" />
            <size
                android:width="50dp"
                android:height="50dp" />
        </shape>
    </item>
</layer-list>
like image 94
Kasun Thilina Avatar answered Dec 09 '25 14:12

Kasun Thilina



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!