I need to create a custom
Span that renders its content like source code. Here’s an example of what I am trying to achieve. Let’s say we have the following text, where I have annotated the start and end of the custom span using square brackets:
Some text [some\nmulti line\ntext] some more text
The prefix (“Some text”) and suffix (“some more text”) should be rendered normally, but the custom span should be rendered like a code block:
some multi line text
I have been looking at using
ReplacementSpan for this, since i Have previously used that to create various interesting custom spans, but for this case I just can’t get it to do what I want.
I somehow need to get my span to render a full block of graphics, occupying the entire width of the container. Is it even possible to do this?
Android processes multiline spans line-by-line.
The only way I’ve found is to override
TextView.onDraw, compose blocks for each block-span and draw them before (of after, if you want)
And special BlockQuoteSpan.
You should ensure that each block span starts and ends with a