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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:08:42+00:00 2026-05-21T17:08:42+00:00

I have been searching for possibilities to define different shapes inside a single shapes.xml

  • 0

I have been searching for possibilities to define different shapes inside a single shapes.xml and refer to each one on some specific events.

At last I’ve found a solution to my question. And the answer is using level-list.

<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:maxLevel="0">
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
          
        <gradient android:startColor="#aaa" 
            android:endColor="#eee" android:angle="270" />
           
        <corners android:bottomRightRadius="7dp"
            android:bottomLeftRadius="7dp" android:topLeftRadius="7dp"
            android:topRightRadius="7dp" />
    </shape>

</item>
<item android:maxLevel="1">
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval">
          
        <gradient android:startColor="#eee" android:centerColor="#ddd"
            android:endColor="#00fff2" android:angle="270" />
           
        <corners android:bottomRightRadius="7dp"
            android:bottomLeftRadius="7dp" android:topLeftRadius="7dp"
            android:topRightRadius="7dp" />
    </shape>
</item>
</level-list>

Apply this to the background attribute in the style. the Interchanging of differents shapes can be achieved by setting the level to that element.

Eg: findViewById(R.id.mybutton).getBackground().setLevel(1);

In the above code I’m setting the second shape to the button with id mybutton.

  • 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-21T17:08:43+00:00Added an answer on May 21, 2026 at 5:08 pm
    <?xml version="1.0" encoding="UTF-8"?>
    <shape 
        xmlns:android="http://schemas.android.com/apk/res/android">
        <stroke android:width="1dip" android:color="#FF8000" />
        <solid 
            android:color="#00FFFFFF"
            android:paddingLeft="10dip"
            android:paddingTop="10dip"/>
        <corners android:radius="10px"/>
    
        <padding 
            android:left="10dip" 
            android:top="10dip" 
            android:right="10dip" 
            android:bottom="10dip" /> 
    </shape>
    

    you can use this for Boarder and any shape ..its for reference…”
    If it is useful so accept the answer and vote up the answer

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

Sidebar

Related Questions

I have been searching for some kind of tool to analyse log files that
I have been searching trying to confirm my reading of the XML spec. My
I have been searching for an answer for this for some time now. I
I have been searching around for free or commercial AR toolkits and need some
I have been searching everywhere for the following functionality in Lisp, and have gotten
I have been searching high and low for a way to get my silverlight
I have been searching for info on this to no avail. The context of
I have been searching for a way to insert linebreaks in my code for
I have been searching the web for this, but I havent found any decent
I have been searching a solution which puts the fold marks and codes to

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.