How Can I set color And Angle like That Using XMl on Android Studio

Viewed 68
    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <corners android:radius="5dp"/>

    <gradient android:angle="45"
    android:type="linear"
    android:startColor="#999999"
    android:endColor="#00a650" />

    </shape>

How Can I make an XML file like this image? Android studio I tried But couldn't. Angle Should be 30% And make a border diagonally.

Image LInk https://i.stack.imgur.com/cJETA.jpg

1 Answers

You just need to set centerX or centerY together with centerColor (see suggestion below)

<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="rectangle">
    <corners android:radius="5dp"/>
    <gradient
        android:angle="45"
        android:centerColor="#999999"
        android:centerX="0.7"
        android:endColor="#00a650"
        android:startColor="#999999"
        android:type="linear"/>

</shape>
Related