Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do you make a line drawable with a gradient?

So…I wanted to add a line that looks like this line with gradient
and have created a drawable


<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="90"
    android:toDegrees="90">
    <shape
        android:shape="line">

        <stroke
            android:color="#000000"
            android:width="1dp"/>
        <gradient android:startColor="#FFEE8D85"
            android:endColor="#000000"/>
    </shape>
</rotate>

which gives this result line without gradient
what do I do to get the desired result I want?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Make drawable resourse file.

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:type="linear"
        android:angle="90"
        android:startColor="#14b19e"
        android:endColor="#115ede" />
</shape>

Then apply like this

<View
    android:layout_width="1dp"
    android:layout_height="50dp"
    android:background="@drawable/my_gradient_drawable"/>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading