0

I've used the tutorial in this link which demonstrates a great way of using different colors for buttons.

He has demonstrated all the colors for the buttons as below

enter image description here

Ex:: for red He mentions as

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" >
        <shape>
            <solid
                android:color="#ef4444" />
            <stroke
                android:width="1dp"
                android:color="#992f2f" />
            <corners
                android:radius="3dp" />
            <padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" />
        </shape>
    </item>
    <item>
        <shape>
            <gradient
                android:startColor="#ef4444"
                android:endColor="#992f2f"
                android:angle="270" />
            <stroke
                android:width="1dp"
                android:color="#992f2f" />
            <corners
                android:radius="3dp" />
            <padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" />
        </shape>
    </item>
</selector>

But he has not mentioned the color for Orange in the

  • Can someone give a demonstration with Orange color
  • Specifications must be same as the ones mentioned for other colors but color must be orange
1
  • 2
    All you need to do is change the hex colors for each of the shapes. You should be able to determine the basic pattern he sets up in his blog post and swap out the hex colors (e.g. #ef4444) for an orange (e.g. #ff8800). However, there are a nearly infinite number of shades of orange and combinations that can form a gradient, so it's up to you to pick the exact colors. Commented Oct 2, 2013 at 17:16

2 Answers 2

3

Check all color codes here

just replace your desired color in

 <item>
        <shape>
            <gradient
                android:startColor="#ef4444"
                android:endColor="#992f2f"
                android:angle="270" />
            <stroke
                android:width="1dp"
                android:color="#992f2f" />
            <corners
                android:radius="3dp" />
            <padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" />
        </shape>
    </item>

These two lines

  android:startColor="#ef4444"
   android:endColor="#992f2f"

padding is the inside spacing and stroke is the width of boundary of button. just replace the colors in gradient tag and make your desired button.

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

Comments

0

I just wanted to post the code for answer ( thanks to Brontok & Tanis .7x)

I found the solution::

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" >
        <shape>
            <solid
                android:color="#ff8800" />
            <stroke
                android:width="1dp"
                android:color="#992f2f" />
            <corners
                android:radius="3dp" />
            <padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" />
        </shape>
    </item>
    <item>
        <shape>
            <gradient
                android:startColor="#ff8800"
                android:endColor="#992f2f"
                android:angle="270" />
            <stroke
                android:width="1dp"
                android:color="#992f2f" />
            <corners
                android:radius="3dp" />
            <padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" />
        </shape>
    </item>
</selector>

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.