An Android Spannable is an interface for text to which markup objects can be applied.
Questions tagged [spannable]
302 questions
6
votes
4 answers
ImageSpan on EditText (smileys). With SwiftKey Keyboard doesnt work
I am doing a simple chat application and i want to show smileys on edittext while writing the message.
I have this to identify wich characters will be subsituted by an Image throught an ImageSpan (this is called only when an smileys character is…

Igor
- 222
- 4
- 14
5
votes
0 answers
In StyleSpan, why Typeface to NORMAL can not be applied over the Typeface to BOLD?
Button btnBold = (Button) findViewById(R.id.btnBold);
btnBold.setOnClickListener(new OnClickListener() {
@Override
public void onClick (View v){
startSelection = etx.getSelectionStart();
endSelection =…

Sumitkumar Dhule
- 409
- 5
- 10
5
votes
1 answer
Android: "nowrap" in Spannable in TextView
Is it possible to have a spannable in TextView similar to this functionality in WebView?
Bob McDonalds <b.mcdonalds@domain.com>
I am trying to avoid
|Email: Bob McDonalds

700 Software
- 85,281
- 83
- 234
- 341
5
votes
2 answers
Change the colour of text as the user types hash tags
I am working on an application where the user can post content to a feed. In my edit text (used for composing) the text colour is grey. However when the user types a hash tag e.g. #help I need to colour that text black as they type, so when the…

DJ-DOO
- 4,545
- 15
- 58
- 98
5
votes
0 answers
Multiple alignment spans in one TextView don't work?
I need to have a text view displaying two texts - one of them left aligned, the other - right aligned. After reading about spans, I composed the following code:
private Spannable generateText(PageModel page) {
final DateFormat dateFormat =…

George
- 3,727
- 9
- 31
- 47
5
votes
3 answers
Android Spannable text save/store issue
I got a edittext and it has multiple coloured text like that code below. Is there any way to store text and colours and show them again? I used to use SharedPreference to store strings integers etc. but this isn`t working for Spannables.
Spannable…

user2638084
- 191
- 1
- 5
- 15
5
votes
1 answer
MonoDroid GetSpans last parameter
I'm trying to use ISpannable in a Monodroid project but am having problems with GetSpans. What I'm ultimately after is a Rich Text editor such as…

Dave W
- 355
- 3
- 11
5
votes
1 answer
Difference between Spannable and String in android
Curiously want to know what is the purpose of Spannable in android. Isn't char array sufficient?

DraD
- 211
- 1
- 3
- 7
4
votes
3 answers
Make TextView "\n" ignore paragraph creation
I have a string of text like this with few newline control characters.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\nUt enim ad minim veniam, quis nostrud exercitation…

rwojcik
- 1,030
- 9
- 18
4
votes
2 answers
StyleSpan is not applied on SpannableString in TextView
I want to make specific substring's font BOLD.
Here is my code:
String fullName = "some name";
String searchFreeText = "some";
SpannableString wordToSpan = new SpannableString(fullName);
Typeface helvticaBoldTypeface =…

Natalie
- 163
- 1
- 3
- 15
4
votes
2 answers
spannableStringBuilder not working with multiple span in single text view
Below is a utility class to make a spannable string with required formatting
package impressico.com.testfragmentstack;
import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.text.Spannable;
import…

RQube
- 954
- 3
- 13
- 28
4
votes
0 answers
Draw a character with 2 color in Android
I am trying to achieve a karaoke text animation in a Textview. Something like this:
In order for it to be smooth, I want to find a way to draw a 2-color character(like s in the image).
I found this link but the HalfColorSpan there didn't draw…

Hoang Phan
- 2,146
- 1
- 15
- 16
4
votes
2 answers
How to substring a spannable?
I know how to take substring a normal string.
But how can I substring a spannable.
Consider following example.
This is my sample sentence.
now when I substring this i want to get the string "mple sente" just like this and with all this formatings.…

SadeepDarshana
- 1,057
- 18
- 34
4
votes
2 answers
Android EditText: how to apply spans when composing?
How can I apply spans on EditText text when the user is composing?
For example the user has activated "bold" when composing, so every character input since then should be bold.
I thought about adding text change listener to the EditText and update…

user3705007
- 265
- 4
- 12
4
votes
2 answers
Handle SpannableStringBuilder image in android
I am developing an application in which selected contacts are added to EditText with aclose mark image and when I click on that close mark image the contact should be removed. I have completed code upto showing close mark image but I don't know how…

NareshRavva
- 823
- 3
- 21
- 50