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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:27:53+00:00 2026-06-04T05:27:53+00:00

Been doing a bit of searching. I can see a method to add a

  • 0

Been doing a bit of searching. I can see a method to add a shadow layer to a TextView, but I only want to shadow a span of text. I’m basically doing an EditText where user will be able to change style of text selections. One of those styles being a shadow with color of choice. There are spans for color, size, typeface, etc, but I cannot find something for shadows.

Basically I want to do something like:
(Note code is from Mono Droid, but a Java answer would be helpful as well)

        var N = new ShadowSpan(color,dx,dy,radius); // no such thing?
        int S = txEdit.SelectionStart;
        int E = txEdit.SelectionEnd;
        Str = new SpannableString(txEdit.TextFormatted);
        Str.SetSpan(N,S,E, SpanTypes.InclusiveInclusive);
        txEdit.SetText(Str, TextView.BufferType.Spannable);
        txEdit.SetSelection(S,E);

Any assistance or suggestion is appreciated. I’m wondering if I have to figure out how to derive my own ShadowSpan implementation from android.text.style.CharacterStyle (maybe override updateDrawState() to setShadowLayer on the TextPaint object?) or perhaps I’m just missing the simple answer? I can’t be the only one who has wanted to do this, so I’d thought I’d ask before going too far with trying something custom.

— EDIT —

I tried creating my own ShadowSpan and it does seem to work. I’m still leaving the floor open if anyone has a better solution. It just seems like something should already exist, but I guess I didn’t have to do too much.

Here is what I have in Mono for Android

public class ShadowSpan : Android.Text.Style.CharacterStyle
{
    public float Dx;
    public float Dy;
    public float Radius;
    public Android.Graphics.Color Color;
    public ShadowSpan(float radius, float dx, float dy, Android.Graphics.Color color)
    {
        Radius = radius; Dx = dx; Dy = dy; Color = color;
    }

    public override void UpdateDrawState (TextPaint tp)
    {
        tp.SetShadowLayer(Radius, Dx, Dy, Color);
    }
}

Used like so

    void HandleClick (object sender, EventArgs e)
    {
        var N = new ShadowSpan(1,1,1,Android.Graphics.Color.Red);
        int S = txEdit.SelectionStart;
        int E = txEdit.SelectionEnd;
        Str = new SpannableString(txEdit.TextFormatted);
        Str.SetSpan(N,S,E, SpanTypes.InclusiveInclusive);
        txEdit.SetText(Str, TextView.BufferType.Spannable);
        txEdit.SetSelection(S,E);
    }
  • 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-04T05:27:55+00:00Added an answer on June 4, 2026 at 5:27 am

    Having thought about it more, it seems pretty simple to implement custom spans by deriving from CharacterStyle. I would guess Google didn’t want to bloat the API with a bunch of one-off Span classes. I guess in the process of constructing my question I’ve ended up answering it. Well, hopefully this help someone else out some day. Thanks to all who posted suggestions.

    public class ShadowSpan : Android.Text.Style.CharacterStyle
    {
        public float Dx;
        public float Dy;
        public float Radius;
        public Android.Graphics.Color Color;
        public ShadowSpan(float radius, float dx, float dy, Android.Graphics.Color color)
        {
            Radius = radius; Dx = dx; Dy = dy; Color = color;
        }
    
        public override void UpdateDrawState (TextPaint tp)
        {
            tp.SetShadowLayer(Radius, Dx, Dy, Color);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been doing quite a bit of searching, but haven't been able to find
I've been doing a bit of research and can't for the life in me
I have been doing a bit of research, but I cannot seem to find
I have been doing a bit of research on this but, I am having
I can't seem to find this on msdn been searching for a bit (described
Been doing a bit of digging about this, but, no luck finding information I'm
I have been doing a bit of reading on this, but I am starting
Ok, so I've been doing a bit of research into NoSQL databases, and they
I've been doing quite a bit of simple XML-processing in python and grown to
I've been doing ASP.NET a little bit (on and off) over the last year,

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.