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 8533883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:04:02+00:00 2026-06-11T10:04:02+00:00

I recently stumbled upon a solution that emulates the android button style through XML

  • 0

I recently stumbled upon a solution that emulates the android button style through XML items. The problem is, I would have to create a different xml file for each button that my uses. (I am making a painting application with 16+ colors, so 16+ buttons) I tried to embed his XML items into a style, a drawable, and even another item so that I could keep all 16 or so buttons in one file. I keep getting “Error: Error parsing XML: unbound prefix” when I try to debug it. I am very new to the android programming scene and this is the first app that I have written in Java. (I am using the MIT app inventor software to plan my apps. Design, simple coding and the sorts). Here is my style. (Note: this is not the entire XML file, just the xml that I use for my buttons.

<style name="test">
    <item android:state_pressed="true">
        <shape>
            <gradient
                android:startColor="@color/yellow"
                android:endColor="@color/gold"
                android:angle="270" />
            <stroke
                android:width="3dp"
                android:color="@color/grey5" />
            <corners
                android:radius="3dp" />
            <padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" />
        </shape>
    </item>

    <item android:state_focused="true" >
        <shape>
            <gradient
                android:endColor="@color/gold"
                android:startColor="@color/black"
                android:angle="270" />
            <stroke
                android:width="3dp"
                android:color="@color/grey5" />
            <corners
                android:radius="3dp" />
            <padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" />
        </shape>
    </item>
    <item>        
        <shape>
            <gradient
                android:endColor="@color/blue"
                android:startColor="@color/lime"
                android:angle="270" />
            <stroke
                android:width="3dp"
                android:color="@color/grey5" />
            <corners
                android:radius="3dp" />
            <padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" />
        </shape>
    </item>
</style>

When that (minus the style tags) is put inside its own file and used as the background property of the button, it works fine, but when its ’embedded’ into a style it doesn’t work anymore. Is there a simple solution to put all of my buttons configurations in one file?

  • 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-06-11T10:04:03+00:00Added an answer on June 11, 2026 at 10:04 am

    Try defining a parent style (such as the style you have posted) and define other styles you need as extending that parent style.

    <style name="yourChildStyle" parent="yourParentStyle"> 
    ... Here go attributes specific to your child style
    </style>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently stumbled upon an open source project that I would like to
I have recently stumbled upon a problem with selecting relationship details from a 1
A problem that I stumbled upon recently, and, even though I solved it, I
Recently I stumbled upon a problem that involves moving asp classic sites from a
Recently stumbled upon a stock video footage site http://www.pond5.com/stock-video-footage/1/*.html , and saw that they
I recently stumbled upon a jQuery plugin that was supposed to force IE to
I've recently been developing on the django platform and have stumbled upon Django Forms
I have recently stumbled into this really neat api for showing callOutbubbles in android
I had recently stumbled upon a common problem in Git when creating branch groups:
Recently, I have stumbled upon the basic understanding about PKI work-in-action process. I have

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.