Creating a triangular shaped button for android application

跟風遠走 提交于 2019-11-29 07:28:16

it is possible to do this using shape: name this arrow UP:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <rotate
            android:fromDegrees="45"
            android:toDegrees="45"
            android:pivotX="-40%"
            android:pivotY="87%" >
            <shape
                android:shape="rectangle" >
                <stroke android:color="@color/transparent" android:width="10dp"/>
                <solid
                    android:color="@color/your_color_here" />
            </shape>
        </rotate>
    </item>
</layer-list>

usage:

<Button
    android:layout_width="70dp"
    android:layout_height="70dp"
    android:background="@drawable/arrow_up" />

for the other triangle:

<Button
    android:layout_width="70dp"
    android:layout_height="70dp"
    android:rotation="180"
    android:background="@drawable/arrow_up" />
Periya Nayagam

Triangle towards right:

<?xml version="1.0" encoding="utf-8"?>
<rotate
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="48"
    android:pivotX="115%"
    android:pivotY="95%"
    android:toDegrees="48">

    <shape android:shape="rectangle">

        <stroke
            android:width="10dp"
            android:color="#c6802a" />

        <solid android:color="#c6802a" />

    </shape>
</rotate>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!