Questions tagged [imagespan]

58 questions
58
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
  • 12,878
  • 10
  • 66
  • 83
47
votes
10 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
  • 36,506
  • 12
  • 75
  • 103
23
votes
3 answers

Is there any way to insert an ImageSpan in a TextView without disrupting the text?

It seems that in order to add an ImageSpan to a Spannable in Android, I have to actually replace some text with the Image. For example: Spannable span = new SpannableString("Foo imageplace Bar!"); Drawable android =…
yuttadhammo
  • 4,879
  • 6
  • 32
  • 44
12
votes
3 answers

How to handle onClick event on imageSpan in editText?

i am working on an app in which user choose an image from gallery and it will be added in editText, now i want if user click on image in editText it should open in fullScreen, i used below code :- public void addToEdt(Bitmap bitmap){ …
user5211136
11
votes
4 answers

How to use the Image(Stored Image of device) with Text on TextView Android?

I am creating the chat app , in which i am getting the EMOJI from the server (IMAGE URLS). I am using this images(Emoji url) with text in my TextView by below lines of the code. String stringWithHtml = "Sample string with an
Ravindra Kushwaha
  • 6,734
  • 9
  • 42
  • 85
9
votes
5 answers

ImageSpan not working on Android 5

I have this function that works fine on Android 4.4.1, but breaks on 5.0+. public static SpannableStringBuilder prependImage(Drawable drawable, String text) { SpannableStringBuilder builder = new SpannableStringBuilder(" " + text); …
i_am_jorf
  • 51,120
  • 15
  • 123
  • 214
9
votes
1 answer

ImageSpan.ALIGN_BASELINE when TextView has lineSpacing

I want to align my ImageSpan to the baseline of the text, but I also need to add some spacing between the lines. The problem is that when I add line spacing, the ImageSpan doesn't align to the baseline of the text, but to the baseline+lineSpacing,…
Rick Sanchez
  • 3,793
  • 1
  • 22
  • 40
7
votes
1 answer

Reduce ImageSpan height and width

I'm setting an Image Drawable as a SpannableString to a TextView but the image comes out larger than the text making it look weird. I need to reduce the size of the imagespan such that it's the same height as the text: Here's what I've…
Dinuka Jay
  • 4,233
  • 6
  • 53
  • 121
6
votes
4 answers

TabLayout Icon not showing

I'm trying to make tab with tablayout following this https://guides.codepath.com/android/Google-Play-Style-Tabs-using-TabLayout#add-custom-view-to-tablayout Now I'm trying to show icon instead of text using the imagespan. But without luck, can…
Yoh Hendry
  • 277
  • 4
  • 14
4
votes
1 answer

TextView with ImageSpan messes up line height

I have a TextView filled with text that should contain some ImageSpan objects. The images can be taller than the normal line height which causes the following problem: if the image is the last object of a line, the following lines' height is…
Gergely Kőrössy
  • 5,110
  • 3
  • 21
  • 39
3
votes
2 answers

How to apply the background color for the ImageSpan in Android?

I want to apply the background color for the Image span dynamically in Android. Could you please suggest any ideas?
Deva
  • 130
  • 1
  • 2
  • 16
3
votes
2 answers

Clicking on ClickableSpan in CheckBox changes its state

I've got an ImageSpan and ClickableSpan in my checkbox to display icon at the end of checkbox text and handle clicking on it. But clicking on it changes checkbox checked state, which is not needed. How can I prevent changing checkbox state when user…
Kamo Spertsian
  • 626
  • 1
  • 8
  • 22
3
votes
0 answers

Copy and paste ImageSpan inside EditText in android

i have an edittext which contains SpannableString with text and ImageSpan, i would like when i long press on an ImageSpan to know which Drawable i clicked (or the index in SpannableString) and convert it to uri to copy it to clipboard. after that…
3
votes
2 answers

Duplicate images appear in EditText after insert one ImageSpan in Android 4.x

I have below code slice to insert a bitmap into an EditText widget. With Android 5.x, it works fine, but with Android 4.x, duplicate images will show after insert one bitmap. Dose anyone know how to fix this with Android 4.x? …
Jerry
  • 31
  • 1
3
votes
2 answers

TextView with ImageSpans inside RecyclerView = wrong layout

I'm inserting ImageSpans inside TextViews, which are part of a RecyclerView. Most of the time it works fine, but as you scroll up and down sometimes the TextView height is wrong for no obvious reason - there's too much vertical whitespace. In this…
foo64
  • 1,925
  • 3
  • 16
  • 25
1
2 3 4