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

526 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
  • 137
  • 1
  • 14
12
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
  • 189
  • 1
  • 1
  • 12
12
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
  • 156
  • 1
  • 6
12
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
  • 250
  • 1
  • 3
  • 11
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
  • 5,802
  • 20
  • 59
  • 91
12
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
  • 553
  • 2
  • 5
  • 13
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
  • 7,800
  • 11
  • 59
  • 121
11
votes
7 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…
qbait
  • 2,934
  • 2
  • 22
  • 39
10
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,355
  • 1
  • 16
  • 20
10
votes
1 answer

Setting a spannable string not working on a simple Textview

I cannot for the life of me understand why this simple code to set a spannable string is not working on this textview. The method below adds a "Today" marker, which should be in green, before the text displaying the date if the date is the current…
TonyKazanjian
  • 259
  • 2
  • 12
10
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
  • 651
  • 5
  • 17
10
votes
3 answers

Android EditText: How to create an empty bullet paragraph by BulletSpan?

I use the same title with this question, because I think my question is very similar to that one, I read and tested the accepted answer very carefully, however the accepted answer doesn't work for me. Let me describe my question: My code looks…
10
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,014
  • 14
  • 29
10
votes
1 answer

Get Spannable String from EditText

I have set a SpannableString to an EditText, now I want to get this text from the EditText and get its markup information. I tried like this: SpannableStringBuilder spanStr = (SpannableStringBuilder) et.getText(); int boldIndex =…
Rahul Chauhan
  • 353
  • 1
  • 3
  • 17
10
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
  • 452
  • 1
  • 8
  • 21
1
2
3
35 36