Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6887041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:50:09+00:00 2026-05-27T05:50:09+00:00

How do we use a layer-list as a drawable for a button. I have

  • 0

How do we use a layer-list as a drawable for a button.
I have a button:

<item android:state_pressed="true">
    <shape>
        <gradient android:endColor="@color/white"
            android:startColor="@color/grey_blue_light" android:angle="90" />
        <stroke android:width="1dp" android:color="@color/aqua_blue" />
        <corners android:radius="3dp" />
        <padding android:left="10dp" android:top="10dp"
            android:right="10dp" android:bottom="10dp" />
    </shape>
</item>


<item android:state_focused="true">

</item>
<item>

</item>

Now I need a layer-list to be used as a shape when say button state is pressed:

<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape android:shape="oval">
        <solid android:color="@color/aqua_blue" />
    </shape>
</item>
<item android:top="1dp" android:left="1dp" android:right="1dp" android:bottom="1dp">
    <shape android:shape="oval">
        <solid android:color="@color/aqua_blue" />
    </shape>
</item>

How do we use this layer list in the button selector?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:50:09+00:00Added an answer on May 27, 2026 at 5:50 am

    Step-1
    create three different layer_list xml under drawable folder for three different state of button. example the name of those xml is layer1.xml, layer2.xml, layer3.xml

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list
        xmlns:android="http://schemas.android.com/apk/res/android"
        >
        <item>
            <shape
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:shape="rectangle"
                >
    
                <gradient
                    android:angle="270"
                    android:startColor="#0000ff"
                    android:endColor="#0000dd"
                    android:type="linear"
                    />    
            </shape>
        </item>
    
    </layer-list>
    

    Step-2
    create a selector xml named as btn_background.xml and pass the layer_list xml in drawable attribute

    <selector
        xmlns:android="http://schemas.android.com/apk/res/android">
    
        <item android:state_pressed="true" android:drawable="@drawable/layer1">
    
        </item>
    
        <item android:state_focused="true" android:drawable="@drawable/layer2">
    
        </item>
    
        <item android:drawable="@drawable/layer3">        
    
        </item>
    </selector>
    

    step-3
    Set the selector xml as background of the button android:background="@drawable/btn_background"

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom drawable in my android project that should be the background
We have our Data Access Layer setup to use repositories, services, and specifications (for
I am returning IList from Business layer. But in viewmodel I have to use
let us assume that I have a reusable business layer that further makes use
What do you think/use for interface layer? The backing layer will be Spring 3.
The examples I can find use a two layer architecture, where the controllers directly
Is it OK - best practise wise - to use the second layer to
I've been investigating what data layer to use for a new web-based project I'm
We use Selenium to test the UI layer of our ASP.NET application. Many of
I use Entities Framework to implement my data accsee layer in ASP.NET MVC. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.