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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:54:27+00:00 2026-05-27T16:54:27+00:00

I have this shape defined in an xml file, and need to create it

  • 0

I have this shape defined in an xml file, and need to create it in code but am stumped.

I assume I want to instantiate a RoundRectShape and set its properties to those in xml, but properties don’t line up very well.

RoundRectShape(float[] outerRadii, RectF inset, float[] innerRadii)

My xml shape only has 1 radius, now RectF, and the RoundRectShape has no options for setting padding or colors?

<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="#00FFFFFF" />
    <stroke android:width="2dp" android:color="#FFFFFFFF" /> 
    <padding android:left="7dp" android:top="7dp" 
            android:right="7dp" android:bottom="7dp" /> 
    <corners android:radius="4dp" /> 
</shape> 
  • 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-27T16:54:27+00:00Added an answer on May 27, 2026 at 4:54 pm

    You need to create custom drawable siomething like the following

    Sample Code

    public class CustomDrawable extends ShapeDrawable{
        Paint fillpaint, strokepaint;
        private static final int WIDTH = 2; 
    
    @Override
    protected void onDraw(Shape shape, Canvas canvas, Paint paint) {
        // TODO Auto-generated method stub
    //  super.onDraw(shape, canvas, paint);
        fillpaint = this.getPaint();
        strokepaint = new Paint(fillpaint);
        strokepaint.setStyle(Paint.Style.STROKE);
        //to set stroke width and color instead of <stroke android:width="2dp" android:color="#FFFFFFFF" /> 
        strokepaint.setStrokeWidth(WIDTH);
        strokepaint.setARGB(255, 255, 255, 255);
    
        shape.draw(canvas, fillpaint);
        shape.draw(canvas, strokepaint);
    
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried to create rectangle like this, in xml with shape but no
I have this code in jQuery, that I want to reimplement with the prototype
I'm building a music events website and want to have a 'share this event'
I'm thinking about how to do this, but I have several different shapes of
I have this idea for a free backup application. The largest problem I need
I have the following shape XML: <?xml version=1.0 encoding=utf-8?> <shape xmlns:a=http://schemas.android.com/apk/res/android a:shape=ring a:innerRadiusRatio=3 a:thicknessRatio=8
I don't know if this is the correct website, but you guys have been
I have a shape that is defined by an outer border and then an
This is what my build.xml file looks like: <project name=test xmlns:cpptasks=antlib:net.sf.antcontrib.cpptasks> <target name=build-native> <mkdir
In an XML document, I have elements which share the same name, but the

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.