Questions tagged [spannable]

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

302 questions
4
votes
1 answer

how set margin between spannable textview?

I am trying to create spannable textview and showing it in EditText. So user can type something in EditText and if user pressed enter button of keyboard then i am converting this text in to spannable textview after this user can start typing again…
Sandip Armal Patil
  • 6,241
  • 21
  • 93
  • 160
4
votes
1 answer

How do I achieve a Facebook Messenger/ Google Hangouts like layout to preview selected items in search bar on ANDROID?

Basically what I want to create can be best illustrated from a screenshot. I have a listview of people just like FB Messenger app. I want the ability for my users to have a search bar like the one shown in the screenshots. It should have the…
3
votes
1 answer

How to create a empty bullet paragraph by BulletSpan?

I wanted to create a empty bullet paragraph, but it didn't work. This is my code: EditText contentET = (EditText) findViewById(R.id.content); contentET.setText("abc\n123\n"); Spannable s = contentET.getText(); s.setSpan(new BulletSpan(), 0, 1,…
Leo
  • 1,433
  • 23
  • 40
3
votes
1 answer

Making multiple parts of a SpannableStringBuilder Bold

I am trying to get a string in a TextView which should look like this: BOLD not bold BOLD not bold I have tried this code: val builder = SpannableStringBuilder() val boldSpan = StyleSpan(Typeface.BOLD) val spanFlag =…
Jordy
  • 121
  • 2
  • 13
3
votes
1 answer

Getting the Text Size of a Spannable TextView

I have a button which increases the size of selected text when clicked. I want it to increase to a certain size, e.g. 36sp, then after that, it stops. I am using a RelativeSizeSpan for this. text.getTextSize() seems to be returning a constant value,…
Prox
  • 639
  • 10
  • 15
3
votes
1 answer

Memory Leak in Custom Textview with Spannable Android

I have one custom textview which has five city names and spannable click listener for each one of them. Code is as follow /** * Created by @raj on 26/04/18. */ class TopCitiesTextView : TextView { private var mListener: OnCityClickListener?…
Raj Suvariya
  • 1,592
  • 3
  • 14
  • 36
3
votes
0 answers

Custom URLSpan don't trigger onClick event, using kotlin

I have this layout: And this code to implement and set my…
Raymond Arteaga
  • 4,355
  • 19
  • 35
3
votes
0 answers

Android: two non-breakable Spans (draw two spans as one)

I have a TextView, to which I'm setting SpannableString combining different Spans (ImageSpan, CalligraphyTypefaceSpan) showing icon-text pairs: It works as I expect, but on the line break, the icon and the corresponding text are getting divided. I…
Georgiy Shur
  • 748
  • 1
  • 8
  • 19
3
votes
1 answer

How to prevent deleting a spannable in an EditText

Is there a way to prevent a user from deleting or modifying a spannable in an EditText? More specifically, I have an ImageSpan as the first character of the EditText. I want to ensure the user cannot delete that ImageSpan. I realize I can use…
Peri Hartman
  • 19,314
  • 18
  • 55
  • 101
3
votes
1 answer

Add an image to iText pdf in Android

I have an String containing images like "My string [img src=image_from_drawable/] blablabla". I'm able to parse this string as Spannable to show that drawable on my TextView, with the following code: static public Spannable formatAbility(String…
3
votes
0 answers

Spannable text with icon shows wrong icon color

In our project we set group name via Spannable with colored icon. When I open activity this works fine. Then I go to next screen where we have same Spannable string but with different icon tint. This screen also works fine with correct color. But if…
Rafael
  • 6,091
  • 5
  • 54
  • 79
3
votes
1 answer

Android notification InboxStyle() with colored string

Quick question with android InboxStyle(), can I have a colored string? I tried using Spannable like NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle(); text = "sample"; Spannable spannable = new…
diggin
  • 47
  • 6
3
votes
1 answer

Android: Make a part of TextView's text NOT-clickable at runtime?

I used Android.text.style.ClickableSpan to make a part (Black) of a string (Blue | Black) clickable: SpannableString spannableString = new SpannableString("Blue | Black "); ClickableSpan clickableSpan = new ClickableSpan() { @Override …
Solace
  • 8,612
  • 22
  • 95
  • 183
3
votes
1 answer

LeadingMarginSpan on multiple paragraphs

I have multiple paragraphs in one TextView and I am trying to achieve a kind of "Tabular" effect. The first line has a zero indentation and a tab indent (I use a TabStopSpan for this) and the rest use a LeadingMarginSpan.Standard(0, INDENTATION) for…
Rameez Hussain
  • 6,414
  • 10
  • 56
  • 85
3
votes
1 answer

How can I remove content from