1

enter image description here

Please suggest someone how to create button like this with xml style in android, without using any image only with the help of color ,shape and style.

2 Answers 2

4

Use layer-list for this.Try the below code

<Button
        android:id="@+id/button_register"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/button_background"
        android:text="Cancel"
        android:padding="15dp"
        android:textStyle="bold"
         />

button_background.xml

    <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item>
        <shape android:shape="rectangle" >

    <gradient
        android:endColor="#FFFFFF"
        android:startColor="#A9A9A9"
        android:type="linear" />


            <stroke
                android:width="2dp"
                android:color="#5E2612" />


            <corners
                android:bottomLeftRadius="10dp"
                android:bottomRightRadius="10dp"
                android:topLeftRadius="10dp"
                android:topRightRadius="10dp" />
        </shape>
    </item>
    <item
        android:bottom="4dp"
        android:left="4dp"
        android:right="4dp"
        android:top="4dp">
        <shape android:shape="rectangle" >
            <gradient
                android:angle="90"
                android:endColor="#A9A9A9"
                android:startColor="#FFFFFF"
                android:type="linear" />

            <corners
                android:bottomLeftRadius="10dp"
                android:bottomRightRadius="10dp"
                android:topLeftRadius="10dp"
                android:topRightRadius="10dp" />


        </shape>
    </item>

</layer-list>

It should work

image

Sign up to request clarification or add additional context in comments.

2 Comments

it now working please suggest me how to do like mentioned image
This style is almost same as your desired image.Let me know what more you want?
3

Check out these examples how to create custum buttons. Link1 Link2

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.