Android: Make a button with triangle shape using xml definitions (drawable)

admin

Administrator
Staff member
I want create this using button (TextView) by using XML definiton:

<img src=" " alt="my image">

In layout of the Activity I have:

Code:
    &lt;TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/button_arrow" &lt;!-- I NEED IMPLEMENT THIS --&gt;
        android:clickable="true"
        android:drawablePadding="7dp"
        android:gravity="center"
        android:drawableLeft="@drawable/music_cloud"
        android:onClick="exportSong"
        android:padding="20dp"
        android:text="@string/export_upload"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/dark_yellow_text_color"
        android:textStyle="bold" /&gt;

I founded several posts:

<a href="https://stackoverflow.com/questions/2517589/making-a-triangle-shape-using-xml-definitions">making-a-triangle-shape-using-xml-definitions</a>

<a href="https://looksok.wordpress.com/2013/08/24/android-triangle-arrow-defined-as-an-xml-shape/" rel="nofollow noreferrer">Android triangle (arrow) defined as an XML shape</a>

or <a href="https://stackoverflow.com/questions/26143905/android-make-an-arrow-shape-with-xml">Android - make an arrow shape with xml</a>

I tried modify several XML definition but nothing was good. Is there some easy way how to implement this shape? Also it should have a transparent background.