An Android Spannable is an interface for text to which markup objects can be applied.
Questions tagged [spannable]
302 questions
0
votes
2 answers
Is is possible to make Span single line and end of text to finish with 3 dots?
I'm using Drafty formatting for displaying Quoted messages
If I write long message instead of 'quoted text' (in the picture), it doesn't display as single line and with dots.
How can I display it like this:

Kuvonchbek Yakubov
- 558
- 1
- 6
- 16
0
votes
1 answer
How to select a particular line in dynamic content in android
I need to select a particular line within dynamic content from database. In every row of a table, few lines start with <#c>. I want to select and center the line which starts with <#c>. I am using SpannableString. I am able to remove <#c> but all…

priyanka naskar
- 25
- 6
0
votes
2 answers
Using getSpans method to get all spans in a spannable
I use the following code to get all spans in a spannable string.
SpannableStringBuilder str = new SpannableStringBuilder(editText.getText());
Object [] objectSpans = str.getSpans(0, str.length(), Object.class);
//loop through all spans
for (Object…

user6931342
- 145
- 3
- 11
0
votes
2 answers
I want to highlight the single word of the ArrayList
I want to give background color to the text that I receive from a List. At the moment I can get highlighted all the words, but I would like to exclude the spaces between the words
Initially I tried was to use a Pattern Matcher Regex solution so to…

Ivano
- 25
- 5
0
votes
4 answers
how to set font color code in spannable String?
I want to set the color code in a spannable string.
SpannableString str= new SpannableString("Your new message ");
str.setSpan(new ForegroundColorSpan("#00ff00", 0, 5, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
I have tried the above…

PrajaktaParkhade
- 95
- 2
- 11
0
votes
2 answers
SpannableString doesn't work - displays unchanged data
does anyone have an idea why the following code does not change the data? The "expired" string is added, but neither the font color nor the size is changed.
Spannable expired = new SpannableString(" expired");
expired.setSpan(new…

Kamil
- 113
- 1
- 10
0
votes
1 answer
ClassCastException only on one device
I could see in Crashlytics following issue, from thousands of users, this was seen only on 1 device (SHARP 507SH Android 8.1.0), how come?
Fatal Exception: java.lang.ClassCastException: java.lang.String cannot be cast to android.text.Spannable
…

David
- 3,971
- 1
- 26
- 65
0
votes
1 answer
SpannableString within onTextChanged length not correct
I am trying to use the below code to catch when a user enters the @symbol and then higlights
the proceeding text in the tag_color, no matter where it is typed within the mPostTextView. I am still relatively new to android development…

Brummerly
- 90
- 1
- 11
0
votes
2 answers
How to use bullet symbol to display as output?
I used by coping the bullet symbol and placed in char symbol. But problem is it's displaying the bullet symbol with such blue color in mobile. My Requirement is, it should be black arrow .
Here is my code:
Spannable spannable =…

Star
- 735
- 3
- 13
- 34
0
votes
2 answers
change string color programmatically depending if condition
Is it possible to set multiple colors for different pieces of text inside a TextView with if condition?
Here is my code:
mColoredText = findViewById(R.id.questionText);
String mColoredString = "BLACK RED GREEN YELLOW ORANGE BLUE WHITE";
…

Bonnie7
- 19
- 1
- 10
0
votes
1 answer
ScrollView stops scrolling when child TextView changes it's span
I have a ScrollView with a TextView as it's child view, which changes it's span every second in Runnable called by MainActivity:
MainActivity:
// MainActivity's private members
private ConstraintLayout m_mainLayout;
private UnderlineSpan…

arek
- 61
- 1
- 5
0
votes
0 answers
Android. How to set event click in a piece of text in TextView
I have a string and i want to do like picture (Identify small pieces (like: [Am], [Em]) change color and assign events to it. And assign another event when i click on black text or any whitespace). Do you have any ideas? Help me please!

Phuong
- 1
- 1
0
votes
1 answer
How do I remove Spannables from CheckBox text?
I've added a strike-through to CompoundButton. The gist of how I'm adding the strike-through is:
fun CompoundButton.addStrikeThrough() {
val span = SpannableString(text)
span.setSpan(
StrikethroughSpan(),
0,
…

methodsignature
- 4,152
- 2
- 20
- 21
0
votes
2 answers
How to set part of TextView clickable while hiding the link?
I have a TextView to show recipients of emails, the original string will be something like "FirstName LastName , FirstName LastName , FirstName LastName ". I want to show a string like "FirstName LastName, FirstName…

litaoshen
- 1,762
- 1
- 20
- 36
0
votes
1 answer
Override method (append to other methods) in this class from another java class
I want to set ClickableSpan for a TextView from another class. In ClickableSpan I need to override two methods, updateDrawState() and onClick(). The former method is the same for all TextViews, but the latter, onClick(), is different for any…

Masa
- 290
- 4
- 17