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

526 questions
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,928
  • 6
  • 25
  • 39
9
votes
5 answers

how to get special character with word and its click event

i have a 3 String like this: "@Username: Deliverd your order", "YOU got trophy: KING OF COINS", "There is a package waiting for you to pick up from #surat to #mumbai", what i wanted to do is get username and city name in different color with its…
Sagar Chavada
  • 4,604
  • 6
  • 34
  • 58
9
votes
1 answer

How to use setSpan() in onTextChanged() to save parameters of onTextChanged()?

I am actually trying to do card formatting, for that I am trying to implement what google says from link You are not told where the change took place because other afterTextChanged() methods may already have made other changes and invalidated the…
T_C
  • 3,028
  • 4
  • 24
  • 45
9
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:
9
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
  • 409
  • 5
  • 18
9
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,399
  • 3
  • 43
  • 88
8
votes
3 answers

How to make spannable text clickable with Accessibility mode on

I have a problem statement where i need to run my application with Accessibility setting on, to have talk back feedback, but the problem here is when i click on a TextView which have Spannable link in it, then it reads the full text but dose not…
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
  • 4,754
  • 8
  • 33
  • 70
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,036
  • 9
  • 48
  • 84
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
  • 984
  • 10
  • 32
8
votes
2 answers

Text is messed up with ImageSpan in EditText

I am building a simple chat app where the user has the ability to send text and emoticons. I can send both text and emoticons to another phone. My problems are: 1.When I type something and add an emoticon: Then I cannot type any text right before…
erdomester
  • 11,491
  • 31
  • 126
  • 226
8
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
  • 22,633
  • 38
  • 142
  • 219
7
votes
2 answers

SpannableStringBuilder replace content with Regex

I have the following code in which I am going to mark the contents between the curly braces with SpannableString and remove the curly braces but it gives wrong result. String text = "the {quic}k brown {fox} jumps {over} the lazy dog. {A Quick}…
Muhammad
  • 4,673
  • 3
  • 34
  • 48
7
votes
2 answers

How to dynamically change the text size in Android

I want to implement a function, EditText user when entering text, you can make changes in accordance with the set font size, Such as Google Docs of Office, Now I found a way to SpannableString, but read some examples seem unable to reach my…
Ban Lin
  • 95
  • 2
  • 10
7
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…
Dinuka Jay
  • 4,233
  • 6
  • 53
  • 121
1 2
3
35 36