jay tandel
jay tandel

Reputation: 177

Can we make a triangular background using xml in android studio

I was wondering if we could make a triangular drawable using xml in android studio.

Upvotes: 0

Views: 90

Answers (1)

Harshad Pansuriya
Harshad Pansuriya

Reputation: 20930

As in API 21 you can use Vector drawable. so in the drawable folder create triangle.xml file.

like this way.

triangle.xml

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:height="100dp"
    android:width="100dp"
    android:viewportHeight="100"
    android:viewportWidth="100" >
    <group
        android:name="triableGroup">
        <path
            android:name="triangle"
            android:fillColor="#FF0000"
            android:pathData="m 50,0 l 50,100 -100,0 z" />
    </group>
</vector>

and apply your View background.

Upvotes: 1

Related Questions