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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:39:02+00:00 2026-06-17T06:39:02+00:00

I need to create a custom button graphic with a border, a gradient background

  • 0

I need to create a custom button graphic with a border, a gradient background and a glass effect:

Custom button graphics with "glass" effect

I don’t want to use 9patch or code a custom class, just xml (shapes, layers, …).

Here the XML code I use to draw the button (it doesn’t not include the “glass effect” yet!):

<layer-list>
</shape>

    <!-- item to draw the inner border and the background -->
    <item>
        <shape>
            <stroke
                android:width="4px"
                android:color="#5f87aa" />

            <corners android:radius="10dp" />

            <gradient
                android:angle="270"
                android:endColor="#034b89"
                android:startColor="#03437b" />
        </shape>
    </item>

    <!-- item to draw the outer border (transparent background) -->
    <item>
        <shape>

            <stroke
                android:width="2px"
                android:color="#212121" />

            <corners android:radius="10dp" />

        <solid android:color="#00000000" />
    </item>
</layer-list>

it looks like this:

Custtom button whit no "glass" effect

So what can I do to have also the glass effect on it?

  • 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-17T06:39:03+00:00Added an answer on June 17, 2026 at 6:39 am

    I answer my own question: seems there are no solution to my problem. Only code (and 9-patch) can solve it. So, I make my own button extending the standard “Button”.

    This is the code used to draw the shine effect when regenerating the button graphic:

    //get the drawing rectangle (calculate inner/outer border width)
    RectF sr = new RectF();
    
    sr.set(cr.left + innerBorderScaledSize / 2f, 
           cr.top + innerBorderScaledSize / 2f, 
           cr.right - innerBorderScaledSize / 2f,
    (cr.top - innerBorderScaledSize / 2f 
    + cr.bottom - innerBorderScaledSize / 2f) / 2f);
    
    RectF cor = new RectF();
    cor.set(sr.left, sr.top, sr.left + cornerScaledRaius, sr.top + cornerScaledRaius);
    
    //here the interesting part: draw the shape   
    Path path = new Path();
    path.reset();
    path.moveTo(sr.left, sr.bottom);
    path.lineTo(sr.left, sr.top + cornerScaledRaius);
    path.arcTo(cor, 180, 90);
    cor.set(sr.right - cornerScaledRaius, sr.top, sr.right, sr.top + cornerScaledRaius);
    path.arcTo(cor, 270, 90);
    path.lineTo(sr.right, sr.bottom);
    path.close();
    canvas.drawPath(path, shinePaint);
    

    So I simply draw a custom and rounded semi-transparent shape on the background using a Paint

    Paint shinePaint = new Paint();
    shinePaint.setAntiAlias(true);
    shinePaint.setStyle(Paint.Style.FILL);
    shinePaint.setColor(0x16ffffff);
    

    u

    here the XML code for the button layout:

    <xxx.uicomponents.iconbutton.IconButton
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:background="@drawable/standard_button_background"
    android:textColor="@drawable/standard_button_text"
    android:textStyle="bold"
    android:textSize="14dp"
    android:text="Click me" />
    

    Hope this help!

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

Sidebar

Related Questions

I want to create custom button and I need it to be circle. How
in 1.8.2 I don't want to use the customer themed button. I need to
I need to create a custom push button which will have 3 different background
I use this code to create a custom tinymce button that changes a class
I need to create a custom json for the jit library. Should I use
I'm using the following code to create a custom edit button item: UIButton *editButton
I need to create a custom dropdown that has a button to open it,
I want to create custom ImageButton, but to work like on/ off button. On
I need create custom dialog and put JPanel into it. Is it possible?
Need to create a custom DNS name server using C which will check against

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.