Questions tagged [spannablestring]

Android - SpannableString is a class for text whose content is immutable but to which markup objects can be attached and detached.

SpannableString is a class for text whose content is immutable but to which markup objects can be attached and detached used in Android development.

Reference

Android developer reference

541 questions
10
votes
1 answer

Setting a spannable string not working on a simple Textview

I cannot for the life of me understand why this simple code to set a spannable string is not working on this textview. The method below adds a "Today" marker, which should be in green, before the text displaying the date if the date is the current…
TonyKazanjian
  • 269
  • 2
  • 13
10
votes
3 answers

Android EditText: How to create an empty bullet paragraph by BulletSpan?

I use the same title with this question, because I think my question is very similar to that one, I read and tested the accepted answer very carefully, however the accepted answer doesn't work for me. Let me describe my question: My code looks…
10
votes
1 answer

Android spannable string with line spacing

I have a tag cloud in which the tags have a background color. Unfortunately I am not able to get a line spacing in place. Let's assume this is the text cloud: tag1 tag2 tag3 tagtext4 tagtext5 This is the style for the text view:
10
votes
2 answers

What is the equivalent of Android's "Spannable" in Objective-C

Im on an iOS app that should able to highlight text, and make it clickable too. I read about NSAttributedString in iOS but it still more complicated than Spannable in android. Is there any other Objective c way to do that, if not; what should i do…
Mutawe
  • 6,464
  • 3
  • 47
  • 90
10
votes
1 answer

Get Spannable String from EditText

I have set a SpannableString to an EditText, now I want to get this text from the EditText and get its markup information. I tried like this: SpannableStringBuilder spanStr = (SpannableStringBuilder) et.getText(); int boldIndex =…
Rahul Chauhan
  • 353
  • 1
  • 4
  • 17
10
votes
4 answers

Set different font and color to part of a TextView

I tried this: String s = "Some big string" SpannableStringBuilder sb = new SpannableStringBuilder(s); //normal font for 1st 9 chars sb.setSpan(robotoRegular, 0,9,Spannable.SPAN_INCLUSIVE_INCLUSIVE); //bold font for rest of the…
Archie.bpgc
  • 23,812
  • 38
  • 150
  • 226
9
votes
2 answers

Android Development: How To Replace Part of an EditText with a Spannable

I'm trying to replace part of an Editable returned from getText() with a span. I've tried getText().replace() but that's only for CharSequences. The reason I'm trying to do this is so I can highlight sections of an EditText one after another (after…
AlexPriceAP
  • 1,987
  • 6
  • 26
  • 41
9
votes
0 answers

How to use SpannableString in Android UnitTests

I just stumbled across a problem again where I haven't found a solution yet, so I thought I'd ask you :) Suppose I have the following method (Kotlin): fun getValue(): SpannableString { val value = "MyTestValue" val subString = "Test" …
Thomas Cirksena
  • 717
  • 2
  • 8
  • 28
9
votes
1 answer

Reduce ImageSpan height and width

I'm setting an Image Drawable as a SpannableString to a TextView but the image comes out larger than the text making it look weird. I need to reduce the size of the imagespan such that it's the same height as the text: Here's what I've…
Jay
  • 4,873
  • 7
  • 72
  • 137
8
votes
1 answer

How adding ImageSpan in jetpack compose Text

As we know, AnnotatedString in JetpackCompose has provided some API of Android's SpannedString. but I didn't find any way/workaround to inline ImageSpan to a Text (except using AndroidView)
8
votes
0 answers

How to alpha / translate animate each word in a TextView instead of each character?

I am working with the following Spannable and TextView like so and I've got it animating each character but I want to animate each word how can I accomplish that? Looking to alpha in and translate each word (from the bottom of the location of each…
AndyRoid
  • 5,062
  • 8
  • 38
  • 73
8
votes
2 answers

BackgroundColorSpan adjust height or add a padding to it

I have an app where I am displaying multiple lines, and multiple paragraphs, of formatted text in a TextView. I am using SpannableStringBuilder for this purpose. One of the things I want to do here is to be able to highlight the text. Now I have…
Rameez Hussain
  • 6,414
  • 10
  • 56
  • 85
8
votes
1 answer

Sometimes image spans are not visible when content covers multiple lines in textview

I have a textview and I am trying to draw image spans along with some text in it. Sometimes some of the images are not visible when the content wraps to the next line. Anything that I should keep in mind while adding spans to a textview ? Any other…
Vinayak Bhavnani
  • 618
  • 1
  • 4
  • 10
8
votes
2 answers

Incorect line wrapping when using bulletspan

I'm trying to solve my problem for 2 days now but without any success. The problem is: when I set BulletSpan to text and then display it in EditText everything works fine until I start typing in another text. When the text is wrapped at the end of…
Jan
  • 1,054
  • 13
  • 36
8
votes
3 answers

Align 2 texts, 1 normal, 1 opposite

I make a android application with a button where in there a total of 4 texts and I want to align the first 2. One at the most left side of the bottom text and the other and the right side of the bottom text. So from this: setText(item.title + " " +…
user2784435
  • 329
  • 5
  • 18
1 2
3
36 37