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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:39:01+00:00 2026-06-10T03:39:01+00:00

Im trying to achieve a component to make custom shadows to buttons or other

  • 0

Im trying to achieve a component to make custom shadows to buttons or other components, i know that it will be easier with a 9patch or a png with the shadow, but i want to change it color and size programmatically also in its states (pressed,etc), so i decided to try with 9 images, all in XML so the shadow shades start its gradient from the side of the component.

<!-- Left Shadow layer -->
<item>
    <shape android:shape="rectangle" >
        <gradient
            android:angle="0"
            android:endColor="#FFFF0000"
            android:startColor="#00FF0000" />
    </shape>
</item>

It looks good, the problem is on the corners and with the android:gradientRadius parameter now its set to a fixed size, but in the contextual help is said that can be set in a percentage of the base size 10% or parent size 10%p, what i want its to set a 100%p radius so the gradient will always go from the main color and disappear in the edge of the square.

— EDIT —

The android doc about gradientRadius gradientRadius

<shape android:shape="rectangle" >
        <gradient
            android:endColor="#00FF0000"
            android:startColor="#FFFF0000"
            android:gradientRadius="18"
            android:centerX="100%"
            android:centerY="100%"
            android:type="radial" />
    </shape>

And thats where im now 🙁 i do not know how can i set this size to fit its parent view.

Any help will be appreciated, when im finished with the component i will put the code in an answer 🙂 so typical buttons can have customizable shadows in xml.

An image of the deserved component.

–Edit–

Im still interested in this 🙂 no one has a clue?

Button with radia gradients

  • 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-10T03:39:03+00:00Added an answer on June 10, 2026 at 3:39 am

    I think you should give up with xml and implement drawable in code.
    When you extend Drawable class you can get size as rectangle with getBounds(). Also you can dynamicaly recalculate in onBoundsChange method.
    You can also easily construct gradients and use them in Paint object (setShader method)

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

Sidebar

Related Questions

I am trying to achieve dynamic META information so that it will allow META
im trying to achieve something but i dont really know how I have set
What I am trying to achieve is editing code in vim then running make
I am trying to make an application in which one component captures the screen
I am trying to make it so that when a user clicks something on
I'm trying to make an Android layout: 3 components inside a vertical LinearLayout. The
I am trying to make the editText that shows the text but not as
What I am trying to achieve is to extending a component in Flex and
I'm trying to create an application-bar like set of icons with text that will
Trying to achieve any moving effect while appending an element from one to another

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.