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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:51:01+00:00 2026-06-04T04:51:01+00:00

I added a full border around a view but I need to add just

  • 0

I added a full border around a view but I need to add just the corner as shown image below :

enter image description here

I mean the red corner only .

I tried to adjust the below border xml , but it didn’t work :

<shape xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="rectangle">
    <stroke android:width="10dp" android:height="10dp" android:color="#B22222" /> 
    <solid android:color="#FCE6C9" /> 
    <corners android:radius="20dp"  /> 
</shape>

Any help will be appreciated

  • 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-04T04:51:03+00:00Added an answer on June 4, 2026 at 4:51 am

    I don’t think it’s possible to do this using a ShapeDrawable, as it would require you to use some sort of margin or padding on the drawable itself. There actually is a padding attribute, but unfortunately that only has effect on the content of the View, and not the drawable itself.

    That being said, an easy solution would be to create a 9-patch in stead and apply that as background to the TextView. Just for demonstration purposes: make the 9-patch look somewhat like this:

    Red rounded corner 9-patch example


    Edit:
    On second thought, there’s actually another option that relies on using a LayerDrawable to create the desired effect. It’s a bit tedious to create and I have my doubts it’ll be more efficient than using a 9-patch, but at least you don’t have to render out images, which means that if you need to make e.g. a change in colours, it’s more straightforward.

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    
        <item android:drawable="@drawable/rounded" />
        <item android:drawable="@android:color/white" android:left="30dp"
            android:right="30dp" />
        <item android:bottom="30dp" android:drawable="@android:color/white"
            android:top="30dp" />
        <item android:bottom="30dp" android:left="10dp" android:right="10dp"
            android:drawable="@color/pink" android:top="30dp" />
        <item android:bottom="10dp" android:left="30dp" android:right="30dp"
            android:drawable="@color/pink" android:top="10dp" />
    
    </layer-list>
    

    Some details: @drawable/rounded is the code snippet you posted yourself. The following two items are simply white rectangles with an offset, to create the white edges. Now, since these will also overlay the pink surface, we need two more pink rectangles (again with specific offsets) to counter that. The result is a background that looks exactly like what you’re showing in your question.

    Note that you might want to see if you can optimise this a bit. At the least I’d recommend not hardcoding the offsets (like I did for simplicity), but store them in a dimens.xml file so you can keep these values centralized and consistent by referencing them from both the ShapeDrawable and LayerDrawable.

    Addendum: On pre-ICS (or perhaps pre-Honeycomb) devices, there appears to be an issue with directly referencing colours with the android:drawable attribute. You can however easily get around this by setting up another drawable (be it either a 9-patch or ShapeDrawable) to represent this colour. For example, in the snippet above, you would replace android:drawable="@color/pink" with android:drawable="@drawable/color_pink", where color_pink can simply be an xml file containing:

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
      android:shape="rectangle">
        <solid android:color="#FCE6C9" /> 
    </shape>
    

    Obviously you will need to do the same for all other colours referenced in the LayerDrawable. Tested on Gingerbread 2.3.7.

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

Sidebar

Related Questions

Initially i added full source code for viewer. but it has some format problem
I've been looking around for quite some time but I just can't find the
To add full text search to my App Engine app I've added the following
I have a full screen UIScrollView to display my image. An UIActivityIndicatorView is added
Edit: You can get the full source here: http://pastebin.com/m26693 Edit again: I added some
I added a custom install action to my installer to add one of my
Microsoft Ajax Library has added full object orientation to JavaScript. Is there any library,
So i am using a javascript function to add rows based on need to
I've just added 2 new columns to my user table: photo and sex. For
I added a file to the index with: git add somefile.txt I then got

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.