Creating a triangular shaped button for android application

后端 未结 2 1295
自闭症患者
自闭症患者 2020-12-18 03:10

I need to create 2 buttons arranged like this in my android application:

\"enter

相关标签:
2条回答
  • 2020-12-18 03:40

    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" />
    
    0 讨论(0)
  • 2020-12-18 03:45

    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>
    

    0 讨论(0)
提交回复
热议问题