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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:47:09+00:00 2026-06-13T19:47:09+00:00

how to make a black line around the text for my textView? example on

  • 0

how to make a black line around the text for my textView? example on above image

enter image description here

  • 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-13T19:47:10+00:00Added an answer on June 13, 2026 at 7:47 pm

    Extend the TextView class. Then in the onDraw, draw the text first using black, then draw it again, slightly smaller and using white. For extra “correctness”, add custom attributes to the XML to set the “line around” colour.

    public class myTextView extends TextView{
    
        public myTextView (Context context) {
            this(context, null);    
        }
    
        public myTextView (Context context, AttributeSet attrs) {
            this(context, attrs, 0);            
    
        }
    
        public myTextView (Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);        
            // do extra initialisation and get attributes here
        }
    
        @Override
        protected void onDraw(Canvas canvas) {
    
            // draw first in black
            Paint paint = new Paint();
            paint.setColor(Color.BLACK);
            paint.setTextSize(20);                // text size
            paint.setStyle(Paint.Style.STROKE);
            paint.setTextAlign(Paint.Align.CENTER);
    
            canvas.drawText("My text", 50, 50, paint);
    
            // draw again in white, slightly smaller
            paint.setColor(Color.WHITE);
            paint.setTextSize(18);                // text size
    
            canvas.drawText("My text", 50, 50, paint);
    
    
        }
    
    
    }
    

    The code is not complete as it hardcodes the colours, size and positions but I hope that it is enough for you to work with. You can get the text size and text colour from the XML via attrs in the constructor and add line colour and width as custom attributes (search here or Google).

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

Sidebar

Related Questions

I need to make a checkerboard that is composed of alternating black and white
In mac osx (cocoa), It is very easy to make a blank image of
I'm playing around and try to make a Coloring book for my children and
I need to put an alpha blended gradient border around an image. My problem
I want to make my entire li clickable. If I only had one line
To play around with HTML5 canvas, I decided to make an app which draws
I am attempting to make a gallery that calls the image names from a
I have a working android app using TextView, some formatting (line breaks, rows of
How to make a block of memory allocated by malloc() or new: immediately swapped
I want to make two block stand side by side. In Opera, Chrome and

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.