Questions tagged [spanned]

The Android interface for text that has markup objects attached to ranges of it.

87 questions
48
votes
4 answers

Remove extra line breaks after Html.fromHtml()

I am trying to place html into a TextView. Everything works perfectly, this is my code. String htmlTxt = "

Hellllo

"; // the html is form an API Spanned html = Html.fromHtml(htmlTxt); myTextView.setText(html); This sets my TextView with the…
AlexCheuk
  • 5,595
  • 6
  • 30
  • 35
31
votes
2 answers

EditText scale with selection

I have an EditText I want to zoom it, and scroll with setScaleX/setScaleY and it works fine - text is being edited in the right position. But when I try to select text - it draws selection handles to positions like when text is not scaled. It is…
Yevgen Kulik
  • 5,713
  • 2
  • 22
  • 44
24
votes
5 answers

Android ImageGetter images overlapping text

I'm trying to load a block of HTML into a TextView, including images, using URLImageParser p = new URLImageParser(articleBody, this); Spanned htmlSpan = Html.fromHtml(parsedString, p, null); parsedString is the HTML, by the way. Anyway, it loads…
Nick
  • 6,900
  • 5
  • 45
  • 66
18
votes
1 answer

How to loop through the spans in a SpannedString or SpannableString in Android

If I have a SpannedString (or SpannableString) like this SpannableString spannableString = new SpannableString("Hello World!"); ForegroundColorSpan foregroundSpan = new ForegroundColorSpan(Color.RED); BackgroundColorSpan backgroundSpan = new…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
16
votes
2 answers

What is the difference between SPAN_POINT_MARK and SPAN_MARK_POINT?

I have been reading up on the docs for the Spanned/Spannable class for a project that I am working on. I have been puzzled by the definition and usage of the spans that contain MARK and POINT. A MARK seems to be defined in the Doc as "attached" to a…
Enigmadan
  • 3,398
  • 2
  • 23
  • 35
12
votes
7 answers

android: how to persistently store a Spanned?

I want to save a Spanned object persistently. (I'm saving the String it's based on persistently now, but it takes over 1 second to run Html.fromHtml() on it, noticeably slowing the UI.) I see things like ParcelableSpan and SpannedString and…
Dan Jameson
  • 1,510
  • 13
  • 20
10
votes
4 answers

How come my spannable isn't shown?

Background I'm trying to use a simple SpannableString on a TextView, based on an UnderDotSpan class I've found (here). The original UnderDotSpan just puts a dot of a specific size and color below the text itself (not overlapping). What I'm trying is…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
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…
8
votes
2 answers

Is SpannableString.setSpan() 2nd parm 0-based?

My empirical experiment shows that if I setSpan(o, start, end) from start to end of a string, where end is String.length() - 1, the last character isn't covered. When I changed end to exactly String.length(), the entire string is covered and... I…
uTubeFan
  • 6,664
  • 12
  • 41
  • 65
8
votes
2 answers

android SPAN_EXCLUSIVE_EXCLUSIVE not working properly

I am trying to set span on a SpannableStringBuilder using flag SPAN_EXCLUSIVE_EXCLUSIVE and I am facing problem on further editing the text to which I am setting span. Expected behaviour 1: Original text. 2: Text added before. 3: Text added after…
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
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
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
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
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 4 5 6