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

  • Home
  • SEARCH
  • 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 3631076
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:21:04+00:00 2026-05-19T00:21:04+00:00

I am a beginner. So I request you to be patient with me. I

  • 0

I am a beginner. So I request you to be patient with me.
I am trying to achieve a custom shape for the button instead of the usual rectangular one.
Is there any other way to do this than setting it as background for a button?
Also i am trying to use different colours for different states for the button. Towards this I have created this file:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" 
          android:state_pressed="false" 
          android:drawable="@android:drawable/my_button_background_focus_blue" />
    <item android:state_focused="true" 
          android:state_pressed="true"
          android:drawable="@android:drawable/my_button_background_pressed_blue" />
    <item android:state_focused="false" 
          android:state_pressed="true"
      android:drawable="@android:drawable/my_button_background_pressed_blue" />
    <item android:drawable="@android:drawable/my_button_background_normal" />
</selector>

Do I include this inside the main.xml or create another xml file? If so, where do I create it?
Thank you.

  • 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-19T00:21:04+00:00Added an answer on May 19, 2026 at 12:21 am

    Is there any other way to do this than setting it as background for a button?

    There are more ways, but this is the easier one. You could, for instance, create your own buttons implementing a custom View, but it does not worth the effort.

    Do I include this inside the main.xml or create another xml file? If so, where do I create it?

    You have to create a new XML file. You call it as you want, and place it in the res/drawable folder. Once you have done so, you can reference that file from XML or programatically:

    <Button
        android:background="@drawable/the_name_of_the_xml"/>
    

    Or…

    button.setBackgroundResource(R.drawable.the_name_of_the_xml);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Beginner here trying to get a pipeline working in bash. If somebody can see
Django advanced beginner here. I'm banging my head against the wall trying to figure
I'm a super beginner ASP.NET developer. I read that on every submit the request
Beginner at Django here, I've been trying to fix this for a long time
I am a beginner, trying to learn how to use POCO C++ library (
being a beginner i m trying to develop a very simple service using express
I am a beginner to python and any coding at all for that matter,
I'm a beginner, so forgive any stupidity in advance. I'm using Flask (and by
I'm sure this is a completely obvious beginner question, but trying to find answers
I'm a Grails beginner, so please be patient with me. Currently I'm having hard

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.