0

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?

  • 1
    See https://stackoverflow.com/questions/13929877/how-to-make-gradient-background-in-android. I think, you should remove `rotate` tag. – CoolMind Dec 07 '22 at 12:35

1 Answers1

3

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"/>
ADM
  • 20,406
  • 11
  • 52
  • 83
Dhruv Sakariya
  • 792
  • 4
  • 10