Questions tagged [spannablestring]

Android - SpannableString is a class for text whose content is immutable but to which markup objects can be attached and detached.

SpannableString is a class for text whose content is immutable but to which markup objects can be attached and detached used in Android development.

Reference

Android developer reference

541 questions
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
13
votes
3 answers

Can I convert a Spannable to a String in android in order to load an ExpandableListView?

I created an array, which I then load into a HashMap, which I then use in an ExpandableListView. However, I'd like to have parts of the data display with subscript and superscript for exponents. After much googling, the solution to superscript and…
grassss
  • 199
  • 1
  • 1
  • 15
13
votes
1 answer

spannablestring is not working for programmatically created button

I know SpannableString is possible to set different text size in one textview but if textview is added programmatically it's not working. String s = "Best Ever"; SpannableString ss1 = new SpannableString(s); ss1.setSpan(new RelativeSizeSpan(2f), 0,…
Venky
  • 166
  • 1
  • 6
13
votes
3 answers

Style text of parameter in getString(int resId, Object... formatArgs) method

I have two String resources as such: Give us feedback at %1$s if you want to make the app even better! info@mycompany.com I'd like to style the email part to be blue and…
S Fitz
  • 1,074
  • 15
  • 31
13
votes
2 answers

Aligning ImageSpan to the top of the TextView

Currently, I wish to add an image in between texts and align it to the top of the TextView. Something like this: The only vertical alignments I can find are baseline (which seems to put it right down the center of the text) and align bottom. What…
kiirohana
  • 260
  • 1
  • 3
  • 11
13
votes
8 answers

ReplacementSpan's draw() method isn't called

I set background in string like that: spanString.setSpan(new BackgroundColorSpan(color), 0, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); But I would like to increase left and right padding in this background so I created custom span public class…
jakub
  • 3,576
  • 3
  • 29
  • 55
13
votes
1 answer

Android Spannable Line Height

I have been trying to figure this one out for the last couple of days now, and have had no success... I'm learning android right now, and am currently creating a calculator with history as my learning project. I have a TextView that is responsible…
titanic_fanatic
  • 593
  • 2
  • 5
  • 13
12
votes
1 answer

How can I use onTouchListeners on each word in a TextView?

I would like to assign onTouchListeners to each word in a TextView. (Not to link to something on the internet, but just to continue the game logic inside the app). The general action of my game at this point is to see a TextView, touch a word, if…
elliptic1
  • 1,654
  • 1
  • 19
  • 22
12
votes
2 answers

java.lang.ClassCastException: android.text.SpannableStringBuilder cannot be cast to java.util.ArrayList

I'm using the phonegap Android plugin: EmailComposerwithAttachments https://github.com/phonegap/phonegap-plugins/tree/master/Android/EmailComposerWithAttachments and it occurs the following error when executing startActivitywithResult function. I'm…
Yang
  • 6,682
  • 20
  • 64
  • 96
11
votes
2 answers

Html Tag Handler not called in Android N for "ul", "li"

We have a custom TagHandler in our app for bulleted list etc. html = "
  • First item
  • Second item
"; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { result =…
okmanideep
  • 960
  • 7
  • 23
11
votes
1 answer

How to use setSpan() in onTextChanged() to save parameters of onTextChanged()?

I am actually trying to do card formatting, for that I am trying to implement what google says from link You are not told where the change took place because other afterTextChanged() methods may already have made other changes and invalidated the…
T_C
  • 3,148
  • 5
  • 26
  • 46
11
votes
4 answers

How can i have EditText with Clickable Spannables and still selectable by longClick?

I have TextView with spans of type ClickableStringSpan defined as below: public class ClickableStringSpan extends ClickableSpan { private View.OnClickListener mListener; int color; public ClickableStringSpan(View.OnClickListener…
VSB
  • 9,825
  • 16
  • 72
  • 145
11
votes
2 answers

Replace the characters with Image in string and then set to Textview

This is :) and want to :) replace with :D new image. I have this type of string that is i have got from EditTextbox.NOw i want to replace all ":)" with image1 and ":D" with image2.I want to do like string.replaceall(":)",image1) and…
Nency
  • 482
  • 1
  • 8
  • 21
10
votes
6 answers

how to get special character with word and its click event

i have a 3 String like this: "@Username: Deliverd your order", "YOU got trophy: KING OF COINS", "There is a package waiting for you to pick up from #surat to #mumbai", what i wanted to do is get username and city name in different color with its…
Sagar Chavada
  • 5,169
  • 7
  • 40
  • 67
10
votes
4 answers

How to make spannable text clickable with Accessibility mode on

I have a problem statement where i need to run my application with Accessibility setting on, to have talk back feedback, but the problem here is when i click on a TextView which have Spannable link in it, then it reads the full text but dose not…
1
2
3
36 37