Questions tagged [spannablestringbuilder]

Use this tag for questions related to the SpannableStringBuilder Android API class for text whose content and markup can both be changed.

The SpannableStringBuilder is an Android API class for text whose content and markup can both be changed. It is an excellent way to style strings in a TextView. It allows a TextView to provide different styles to different areas of text.

74 questions
2
votes
0 answers

how to handle textview span style bold issue with langs having semi-characters(like hindi matra: ा ि ी ु) being seperated out?

I need to style some part of text in a TextView like making bold etc. I'm supporting multiple languages but facing an issue when the languages have dependent semi-characters like matra in Hindi which are dependent on other characters. ex : Hindi…
2
votes
2 answers

How can i merge two different spannable object of single string

I have two spannable object for same string and both have different styles. I need to merge all spannable objects and display all styles into TextView. From one of returning from Html.fromHtml() and second return StyleSpan(Bold). I tried…
Krunal Shah
  • 1,438
  • 1
  • 17
  • 29
2
votes
1 answer

Add Background to ImageSpan

I am trying to add a background span to the image. I can set a background span to strings, but the imagespan in the same string does not show the background. This is a sample of what I want, the selected part shows an image and text with background…
2
votes
3 answers

Creating new SpannableStringBuilder returns null

Here is my unit test. Somehow when I create instantiate SpannableStringBuilder instance with a non-null string argument, it appears to be null. What's wrong with this code? public class CardNumberTextWatcherTest { private CardNumberTextWatcher…
Dmitry Smolyaninov
  • 2,159
  • 1
  • 18
  • 32
2
votes
4 answers

Android EditText change colour of a single word while typing (dynamically)

I have an edit text while typing inside edit text if the word starts with # that particular words color should change , i have implemented textwatcher and found that if text starts with # but do not know how to update the color dynamically , Have…
Paru
  • 57
  • 1
  • 7
2
votes
1 answer

SpannableStringBuilder does not keep the style set in the text

I am trying to use SpannableStringBuilder to build a texts which that contains different styles. But the style is lost after appending more strings. public SpannableStringBuilder buildMixStyleText() { SpannableStringBuilder…
2
votes
0 answers

How to Preserve font size using Html.toHtml and restore it using Html.fromHtml?

I am obviously very new to Android. Can anyone help me? I have EditText in which there is a functionality to set the color(different color for text) , fontsize(different font size for text), font family. That I have implemented using…
Pallavi
  • 652
  • 1
  • 10
  • 26
2
votes
1 answer

LineHeightSpan in Android M and lower versions

I wanna add multiple span to a textview with configurable line space. I use LineHeightSpan class defined in android. But it seems it behave differently in Android M and lower versions Here the result in lower version of Android and this is how it…
Hojjat
  • 815
  • 1
  • 10
  • 25
2
votes
3 answers

How to have a SpannableStringBuilder append a span that's inside a formatted string?

Background Suppose I use SpannableStringBuilder to append multiple stuff into it, and one of them is string that I format from the strings.xml file, which has a span inside: SpannableStringBuilder stringBuilder = new SpannableStringBuilder…
1
vote
1 answer

How to Save ImageSpan with text into SQL Lite Database?

I have implemented image in EditEtxt. Its working fine. I want to save the whole editText entities(Text & image) in sql lite database. When i save it to sql only text are showing not images. I also tried with Html.toHtml and Html.fromHtml. Its also…
1
vote
1 answer

How to add multiple image into EditText using spannable or any other way?

I am creating a note taking app, I have done text section and its working properly. Also database working properly. But I want to add image in the EditText. When user add an image, it will place at the EditText cursor position and this task will…
1
vote
1 answer

ClickableSpan and HTML spanned in the same TextVeiw

I am attempting to implement a clickablespan in an existing HTML string in the view. The string already has href's where needed (excluding the span of characters that need to be handled programmatically). The HTML links are working as expected. An…
DevinM
  • 1,112
  • 1
  • 12
  • 29
1
vote
1 answer

Android SpannableStringBuilder IndexOutOfBoundsException

Lately we've been experiencing a lot of crashes in our application due to IndexOutOfBoundsException being thrown by Android internally. The issue happens on screens with static layout that consists of TextViews, Checkboxes and Buttons on API levels…
1
vote
1 answer

How to find index of a substring in a SpannableString

I have a spannable string and I want to find the index of a substring in the spannable string, I don't want to convert it back to a string as the spannable string is already formatted.
Tamzid
  • 47
  • 6
1
vote
1 answer

Spannable String Builder not applying font

I'm trying to build a String that has two different custom fonts applied to it. I've appended the two strings with the respective font into a string builder, but this does nothing to the String at all? Does anyone know why? private fun…
alfietap
  • 1,585
  • 1
  • 15
  • 38