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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:18:58+00:00 2026-05-20T12:18:58+00:00

So I wanted to have a TextView with a cool border around it. I

  • 0

So I wanted to have a TextView with a cool border around it. I couldn’t find any standard way of doing it, so I came up with this:

@drawable/custom_bg_1: A blue rounded shape

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#439CC8"/>
    <corners android:radius="3dp" />
    <padding android:left="10dp" android:top="10dp"
        android:right="10dp" android:bottom="10dp" />
</shape>

@drawable/custom_bg_2: A white rounded shape

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#FFFFFF"/>
    <corners android:radius="3dp" />
    <padding android:left="10dp" android:top="10dp"
        android:right="10dp" android:bottom="10dp" />
</shape>

myactivity.xml: the xml for the activity

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  android:padding="15dp" >

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:padding="2dp"
    android:background="@drawable/custom_bg_1" >

      <TextView android:layout_width="fill_parent"
            android:layout_height="wrap_content"
        android:text="@string/curr_loc"
        android:textSize="15sp"
        android:background="@drawable/custom_bg_2" />

  </LinearLayout>
</Linearlayout>

The outcome:

picture of blue border

What I am doing here is overlapping a white shape background inside a blue shape background to give the effect of a blue border. I can’t imagine this is the best way to get this effect. I have seen other posts that attempt to solve this problem such as this and this, but I feel like they are just as much of a work around as my implementation.

Is there a better way or more standard way of simply putting a border around certain views such as a TextView or should I just stick with the way I am doing it?


EDIT

I changed custom_bg_2.xml to look like this:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#FFFFFF"/>
    <stroke android:width="2dp" android:color="#000000"/>
    <corners android:radius="3dp" />
    <padding android:left="10dp" android:top="10dp"
        android:right="10dp" android:bottom="10dp" />
</shape>

And now I get this result:

blue and black border

It looks like I can achieve an outline by including <stroke ... /> in 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-20T12:18:59+00:00Added an answer on May 20, 2026 at 12:18 pm

    You can probably get by with just custom_bg_2 if you add a <stroke> section:

    <?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
        <solid android:color="#FFFFFF"/>
        <corners android:radius="3dp" />
        <padding android:left="10dp" android:top="10dp"
            android:right="10dp" android:bottom="10dp" />
        <stroke android:color="#439CC8" android:width="2dp" />
    </shape>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I wanted to have a project, and one-to-many with to-do items, and wanted
If I wanted to have Python distributed across multiple processors on multiple computers, what
Let's say I wanted to have an application that could easily switch the DB
Ruby is preinstalled on my Mac and so I wanted to have a look
I've been working on a project in Delphi 7 where I wanted to have
Iam a great fan of javascript frameworks especially jQuery .I have always wanted to
I have a quick little application and wanted to give a try to develop
I have a button which I wanted to flash briefly to get the user's
I have a ListView inside of an Update Panel and wanted to change the
I have a block of code that works and I wanted to ask what

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.