Questions tagged [spannable]

An Android Spannable is an interface for text to which markup objects can be applied.

302 questions
95
votes
10 answers

How set Spannable object font with custom font

I have Spannable object which I want to set its font by a custom font I have loaded before. Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/font_Name.ttf"); Spannable span1 = /*Spannable Item*/; /// I want to set span1 to have tf font…
Mohamed Ghonemi
  • 1,072
  • 1
  • 10
  • 12
90
votes
3 answers

TextView with different textSize

Is this possible to set different textSize in one TextView? I know that I can change text style using: TextView textView = (TextView) findViewById(R.id.textView); Spannable span = new SpannableString(textView.getText()); span.setSpan(arg0, 1, 10,…
woyaru
  • 5,544
  • 13
  • 54
  • 92
89
votes
10 answers

How to get rid of the underline in a Spannable String with a Clickable Object?

I have a Spannable Object with a Clickable Object set to it. When the Spannable String is displayed in the TextView it has blue text and a blue underline (indicating to the user that this Text is Clickable). My problem is how can I prevent appearing…
Ash
  • 1,241
  • 1
  • 9
  • 16
75
votes
5 answers

How to merge some spannable objects?

I divide a spannable object into 3 parts, do different operations, and then I need to merge them. Spannable str = editText.getText(); Spannable selectionSpannable = new SpannableStringBuilder(str, selectionStart, selectionEnd); Spannable…
Eugene
  • 991
  • 1
  • 6
  • 8
63
votes
3 answers

SpannableString with Image example

I am looking for an example of how to build and display Android SpannableString with ImageSpan. Something like inline display of smileys. Thanks a lot.
Asahi
  • 13,378
  • 12
  • 67
  • 87
55
votes
13 answers

Android Compose: How to use HTML tags in a Text view

I have as string from an outside source that contains HTML tags in this format: "Hello, I am bold text" Before Compose I would have CDATA at the start of my HTML String, used Html.fromHtml() to convert to a Spanned and passed it to the…
William
  • 1,255
  • 2
  • 10
  • 9
52
votes
11 answers

Align text around ImageSpan center vertical

I have an ImageSpan inside of a piece of text. What I've noticed is that the surrounding text is always drawn at the bottom of the text line -- to be more precise, the size of the text line grows with the image but the baseline of the text does not…
Karakuri
  • 38,365
  • 12
  • 84
  • 104
47
votes
4 answers

SpannableString: Is it possible to apply two or more RelativeSizeSpans?

I am trying to construct a SpannableString such that it looks like this: Two characters (m, s) should be smaller than the rest. I have tried to hold all the text in one SpannableString, and I also tried to concatenate two SpannableStrings via a…
manmal
  • 3,900
  • 2
  • 30
  • 42
40
votes
3 answers

Android SpannableString set background behind part of text

I would like to create something similar as seen on this image: I managed to create evertyhing with SpannableStringBuilder, except the orange rounded rectangle. I can set the background to that color with BackgroundColorSpan, but I can't find a way…
Adam Ivancza
  • 2,459
  • 1
  • 25
  • 36
39
votes
3 answers

spannable on android for textView

Tweet o = tweets.get(position); TextView tt = (TextView) v.findViewById(R.id.toptext); //TextView bt = (TextView) v.findViewById(R.id.bottomtext); EditText bt =(EditText)findViewById(R.id.bottomtext); bt.setText(o.author); Spannable spn =…
baran
  • 423
  • 1
  • 4
  • 5
31
votes
6 answers

Combining Spannable with String.format()

Suppose you have the following string: String s = "The cold hand reaches for the %1$s %2$s Ellesse's"; String old = "old"; String tan = "tan"; String formatted = String.format(s,old,tan); //"The cold hand reaches for the old tan…
Maarten
  • 6,894
  • 7
  • 55
  • 90
28
votes
1 answer

Button setText with Spannable doesn't work for Android 5.0 Lollipop

I have a simple Button:
klimat
  • 24,711
  • 7
  • 63
  • 70
21
votes
2 answers

Adding a padding/margin to a Spannable

I'm using BackgroundColorSpan to customize parts of a TextView. Here's the code I have: String s = "9.5 Excellent!"; s.setSpan(new BackgroundColorSpan(darkBlue, 0, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); s.setSpan(new BackgroundColorSpan(darkBlue,…
Henrique
  • 4,921
  • 6
  • 36
  • 61
20
votes
5 answers

How to click or tap on a TextView text on different words?

How to move to another view by click on text view with two different words. this is the string i am using. By clicking Sign Up, you are indicating that you have read and agree to the Term of Use and Privacy Policy. i want to make these two words…
RajaReddy PolamReddy
  • 22,428
  • 19
  • 115
  • 166
19
votes
2 answers

select a word on a tap in TextView/EditText

How to select a word on a tap in TextView/EditText in android. I have some text in a TextView/EditText and when user taps on a word, I want that word to be selected and after that when I call getSelectedText() like method, it should return me the…
M-Wajeeh
  • 17,204
  • 10
  • 66
  • 103
1
2 3
20 21