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
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
3 answers

How formatted string and then change style by annotations

i have 3 strings localizations Test testBold %1$s end Тест тестБолд %1$s
mario
  • 632
  • 1
  • 7
  • 16
7
votes
1 answer

java.lang.RuntimeException: PARAGRAPH span must start at paragraph boundary (46 follows )

I am getting the below error While trying to Render the Text in the Text view java.lang.RuntimeException: PARAGRAPH span must start at paragraph boundary (46 follows ) at…
Anbu
  • 671
  • 1
  • 6
  • 18
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
  • 6,725
  • 5
  • 47
  • 54
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
0 answers

How can I make my custom ReplacementSpan wrap?

I'm trying to apply a background with a border to specific text in a TextView. A BackgroundColorSpan works great, but it doesn't have a border. To get the border, I instead use a custom ReplacementSpan and override draw. It looks good for short…
adamdport
  • 11,687
  • 14
  • 69
  • 91
7
votes
1 answer

ForegroundColorSpan is not applied to ReplacementSpan

I'm trying to utilize ReplacementSpans to format the input in a EditText Field (without modifying the content): public class SpacerSpan extends ReplacementSpan { @Override public int getSize(Paint paint, CharSequence text, int start, int…
Andreas Wenger
  • 4,310
  • 1
  • 22
  • 31
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
5 answers

Why doesn't my text show up with style when using SpannableStringBuilder?

I have a problem with a SpannableString object. Below's a short example: SpannableString spanstr = new SpannableString("Bold please!"); spanstr.setSpan(new StyleSpan(Typeface.BOLD), 0, spanstr.length(), 0); SpannableStringBuilder sb = new…
MC Emperor
  • 22,334
  • 15
  • 80
  • 130
6
votes
0 answers

SpannableString doesn't work on Android Unit Test

I try to compare two SpannableStrings texts on my unit test and I receive the error: java.lang.RuntimeException: Method toString in android.text.SpannableString not mocked. See http://g.co/androidstudio/not-mocked for details. After debug, I verify…
6
votes
1 answer

android.widget.Editor: NullPointerException in SpannableStringInternal

I am receiving error reports in Crashlytics for NPEs in SpannableStringInternal but could not reproduce the issue on any phone or determine the source of it. I'm calling for the Internet to help me identify the underlying issue. Fatal Exception:…
whlk
  • 15,487
  • 13
  • 66
  • 96
6
votes
3 answers

Linkify.addLinks with Span not working

I have textview with autoLink, but whenever i add custom span (ClickableSpan) to textview its auto link to web url and mobile number is not working. is there any easy way to solve this issue. Style is applied but click is not working.
Bincy Baby
  • 3,941
  • 5
  • 36
  • 62
6
votes
4 answers

Justifying text inside a TextView in android

So, as most of you know, there is no text justifying inside a TextView in Android. So, I built a custom TextView to get around the problem. However, for some reason, sometimes punctuation marks break the line for some reason in some devices. I…
ShayR
  • 169
  • 1
  • 2
  • 10
6
votes
3 answers

Flutter - spans cannot have a zero length

I am developping a Flutter app which uses a Textfield. I am declaring the TextField like this : new TextField( controller : _controller, decoration : new InputDecoration( hintText: 'Message...' ) ) The TextField is displayed in my…
Alexi Coard
  • 7,106
  • 12
  • 38
  • 58
6
votes
1 answer

Alternative to ReplacementSpan in Android

I have an app that pages large text and sets multiple spans to each word or sentence. I am using ReplacementSpan to draw the background for each word. I cannot use BackgroundSpan because it is too simple and doesn't give me control over the canvas.…
mthandr
  • 3,062
  • 2
  • 23
  • 33