Questions tagged [spannable]

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

302 questions
19
votes
4 answers

How to convert SpannedString to Spannable

Hello I have set some text in a textview. TextView tweet = (TextView) vi.findViewById(R.id.text); tweet.setText(Html.fromHtml(sb.toString())); Then I need to convert the text of the TextView into Spannble. So I did this like: Spannable s =…
Kaidul
  • 15,409
  • 15
  • 81
  • 150
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
13
votes
4 answers

How to use support library fonts feature as a part of the TextView content (using spannable)?

Background The support library (docs here) allows you to use TTF fonts files in the "res/font" folder, either in XML : app:fontFamily="@font/lato_black" or via code: val typeface = ResourcesCompat.getFont(context, R.font.lato_black) The…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
13
votes
3 answers

Edit text view with image and text wrapped around image

I am building a rich text editor. I have implemented text formatting like bold italic etc and also paragraph formatting like blockQuote. Now I would like to add images in editor and text should wrap around it. I have implemented all these using…
Circle
  • 177
  • 1
  • 14
12
votes
5 answers

Rounded Background text like Instagram, ReplacementSpan not working as required

I was trying to do something similar to Instagram below - But i want this curves like Instagram - Now i am stuck in one more problem - When i types,. text does not goes automatically to next line, I have to press return , like normally editText…
karanatwal.github.io
  • 3,613
  • 3
  • 25
  • 57
12
votes
1 answer

How to draw a Spanned String with Canvas.drawText in Android

I want to draw a SpannedString to a Canvas. SpannableString spannableString = new SpannableString("Hello World!"); ForegroundColorSpan foregroundSpan = new ForegroundColorSpan(Color.RED); BackgroundColorSpan backgroundSpan = new…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
12
votes
4 answers

How to handle onClick event on imageSpan in editText?

i am working on an app in which user choose an image from gallery and it will be added in editText, now i want if user click on image in editText it should open in fullScreen, i used below code :- public void addToEdt(Bitmap bitmap){ …
user5211136
12
votes
5 answers

How to retrieve BackgroundColorSpan for selected text in android

I am trying to set BackgroundColorSpan to selected text in my Edit-text. So when i select any text and click on button it will set Background color to that particular text and then i am saving that note to my SDCard with .html format and then again…
InnocentKiller
  • 5,234
  • 7
  • 36
  • 84
11
votes
4 answers

Android: How to combine Spannable.setSpan with String.format?

I'm setting Span to part of the text. Span itself works well. However, the text is created by String.format from Resources and I do not know start and end of part in the text I'm going to set Span to. I tryed to use custom HTML tags in strings.xml,…
Salw
  • 1,880
  • 17
  • 22
11
votes
1 answer

In an EditText, is there a way to disable the autocorrect on a span?

I've got an EditText that can have custom spans and I don't want them to be part of the spell check. I know I could use the flag android:inputType=textNoSuggestions to completely disable the suggestions but I would like to handle it based on the…
Romain Piel
  • 11,017
  • 15
  • 71
  • 106
11
votes
4 answers

TextView selection with Spannable and LinkMovementMethod

What i did so far is a list view of textviews having the normal text and clickable spans: Clicking the span i'm opening the URL, clicking the item View around the textView leads to the listView OnItemClickListener navigating to the item details,…
A-Live
  • 8,904
  • 2
  • 39
  • 74
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
1 answer

Is there any way to focus spannable text for accessibility in Android?

I have a String with multiple Links. I am using SpannableText and It is working perfect except accessibility talk back. Is there any way to give accessibility to Links?
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
6 answers

How to clear formatting of a Spannable Text, including last character?

I am using this code to remove formatting of a spannable text from start till end. The problem is that it is working successfully, but the last character in the text is still bold (or italics/underline). removeSpan is not working on the last…
Rahul Gupta
  • 5,275
  • 8
  • 35
  • 66
1
2
3
20 21