Questions tagged [android-spannable]

33 questions
1
vote
0 answers

Spans strange behavior

Prerequisite I've create a simple project with an EditText and a string "Hello World!" inside. The EditText has a StyleSpan(Typeface.BOLD) applied to it using editText.editableText.setSpan(span, 6, 11, Spannable.SPAN_INCLUSIVE_EXCLUSIVE). The…
1
vote
2 answers

Android - Applying a new StyleSpan removes previously applied Spans

I am making an app that requires the Text Formatting Features such as making the selected text Bold, Italic, Strike through, Underline, etc. I have used the StyleSpan(Typeface.BOLD), StyleSpan(Typeface.Italic), UnderlineSpan(), StrikethroughSpan()…
0
votes
0 answers

How to convert Android spannable to markdown syntex

I'm working on a custom Android editor that is actually based on Android Spannable rendering and later converts the Spannable to Markdown syntax for other clients. it supports BOLD ITALIC STRIKETHROUGH BULLETED LIST ORDERED LIST To achieve…
Muhammad Maqsood
  • 1,622
  • 19
  • 25
0
votes
1 answer

Android. How to get substring from Spannable which was clicked?

I have html string: htmlString = "This is a link and another link link2" I set this String to my TextView. Here is my…
0
votes
1 answer

Android. How to make clickable html string?

I have html string. I need to show my it in my TextView. Here is my code: tvText.setText(Html.fromHtml(htmlString)); Html string contains some text, but may also contains links. I need to detect if a string contains a link, make part of that string…
testivanivan
  • 967
  • 13
  • 36
0
votes
0 answers

how do I highlight the searched text using android search view Widget?

My search view is working properly but I am trying to do a search such that all the "visible" search letters should be highlighted. I used the filter interface in my adapter for filtering data. here is my adapter Class public class myAdapter extends…
0
votes
1 answer

How can I block EditText layout reflow when adding spans?

I am trying to batch-add several thousand spans to a SpannableStringBuilder in an EditText (obtained via getText()). This is slower than I would like. Profiling has shown that the vast majority of the time is being spent in DynamicLayout.reflow. Is…
0
votes
1 answer

Android BackgroundColorSpan breaking with lineSpacing less than 1

I have got a textView to which I do this: textView.setLineSpacing(1f, .70f); and then I would like to set a background color only to specific words in that textView so I've tried this: spannableStringBuilder.setSpan(new…
AndreiBogdan
  • 10,858
  • 13
  • 58
  • 106
0
votes
0 answers

Android. Unit testing for SpannableString

For testing my business logic I'm using mockk library. But I also have a few helper classes that contain methods that use SpannableString, ForegroundColorSpan etc. I need to write tests for these methods as well. However, I do not quite understand…
0
votes
1 answer

How to add horizontal spacing between two Spannables?

I have a custom TextView that combines two pieces of text and have a spacing variable. class MyCustomTextView() { var label: String var value: String var spacingBetweenLabelAndValue: Int = 0 // ... } Each one have their own style and are…
Augusto Carmo
  • 4,386
  • 2
  • 28
  • 61
0
votes
2 answers

Replace certain String with Spans without HTML

I'm trying to replace a certain string with a span. For example I have this String: String s = "redHello greenWorld"; I wanna replace "red" with: modifiedText.setSpan(new ForegroundColorSpan(Color.parseColor("#FF0000")), start, end,…
Qayin
  • 3
  • 2
0
votes
1 answer

The effect of BufferType.Normal and BufferType.Spannable for textView

I have this code: TextView tv1 = FindViewById(Resource.Id.textView1); tv1.Text = "Text"; SpannableString wordtoSpan = new SpannableString(tv1.Text); wordtoSpan.SetSpan(new UnderlineSpan(), 0, tv1.Text.Length, 0); …
user2111639
  • 287
  • 2
  • 5
  • 15
0
votes
1 answer

how can i underline a text word by word?

how can i underline word by word in a sentence in android studio? so my program would be like this if i click a button the underline will start at first and when i click again the button it will move again to the next word. for Example: _The_ ***…
Evil Kick
  • 31
  • 6
0
votes
1 answer

how to set underline in a sentence by button sequence?

I cannot get the method for this but how can I set/modified a String in a sentence with an underline in a textview? i wanted like this, when i click the button the underline will move to the next string and click again the underline will move…
Evil Kick
  • 31
  • 6