Questions tagged [spannable]

An Android Spannable is an interface for text to which markup objects can be applied.

302 questions
9
votes
4 answers

Unable to add ForegroundColorSpan

SpannableStringBuilder sb = new SpannableStringBuilder("Hello World"); ForegroundColorSpan fcs = new ForegroundColorSpan(R.color.text_blue); sb.setSpan(fcs, 5, 11,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); res/Values/color.xml
user1537779
  • 2,311
  • 5
  • 28
  • 45
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
1 answer

Android check if Spanned objects are equal

How can I check if two Spanned objects are equal (they have the same content and spans applied)? I rather not implement the equals(Spanned span) method. :)
Tudor Luca
  • 6,259
  • 2
  • 29
  • 44
8
votes
1 answer

How to get text width when multiple spannable setting

I set span for spannableText and set it to TextView. After i want get width and height of this text. But the result does not take into account the change in the size of the text due to the set span. Next solution is work incorrect. return…
8
votes
1 answer

SpannableString not displayed correctly in Landscape mode

I have a piece of code which adds some image into an EditText using SpannableString as follow: SpannableString ss = new SpannableString("Some random String in my application."); Drawable d =…
Chor Wai Chun
  • 3,226
  • 25
  • 41
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,789
  • 32
  • 132
  • 234
7
votes
0 answers

How to apply Bullet and Numbered List in android Edit-text

I am trying to apply Bulleted list and Numbering list in android edit-text when user press button. For that i have tried below code. For Bullet BulletSpan[] quoteSpan = str.getSpans(selectionStart, selectionEnd, BulletSpan.class); …
user3660803
  • 315
  • 1
  • 3
  • 15
7
votes
1 answer

Paragraph spacings using SpannableStringBuilder in TextView

As the question indicates, I am working on a TextView which will show formatted text using SpannableStringBuilder. It has multiple paragraphs and I would like to know what would be the easiest (or at least the least complicated) way to set spacing…
Rameez Hussain
  • 6,414
  • 10
  • 56
  • 85
7
votes
3 answers

Handle clicks on TextView's links while using Linkify for finding and setting the links inside the text

i have a TextView filled with text which i get from a server. I'm using Linkify for handling all the link searching and for setting a URLSpan where needed throughout its addLinks method. The problem is that the default behavior when clicking a link…
Shirane85
  • 2,255
  • 1
  • 26
  • 38
6
votes
0 answers

How to set gravity center of SpannableStringBuilder?

I'm using two different fonts in one TextView: first is SVG font , second TTF font. To set icon with text to TextView I'm using this: String icon =getContext().getString(iconId);//"" String text =…
NickUnuchek
  • 11,794
  • 12
  • 98
  • 138
6
votes
1 answer

What is markup objects in context of Android Span?

What is markup objects in context of Android Span? android.text.SpanWatcher When an object of this type is attached to a Spannable, its methods will be called to notify it that other markup objects have been added, changed, or removed. What…
Amit Yadav
  • 32,664
  • 6
  • 42
  • 57
6
votes
1 answer

Android Edittext Spannable Issue

Everytime Edittext onAfterTextChange method, i check if some special string(which comes from functionlist variable) is entered then change that string's special color. Code is below for(String s:functionList) { final Pattern p =…
Mert Serimer
  • 1,217
  • 2
  • 16
  • 38
6
votes
2 answers

How to get UnderlineSpan with another color in Android?

I'd like to have Spannable that looks like error in IDEs - underline with another color. I've tried to create ColorUnderlineSpan class that extends android UnderlineSpan, but it makes all the text another color (i need to add colored underline…
4ntoine
  • 19,816
  • 21
  • 96
  • 220
6
votes
1 answer

Convert a spanned to spannable

I have a spanned text that I need to cast to Spannable. Thats what I try to do in my code: Spannable buffer = (Spannable) text; This code is giving me a "can't cast Spannable to Spanned". Is it possible? if so how? Thanks!
roiberg
  • 13,629
  • 12
  • 60
  • 91
1 2
3
20 21