2

I am using Html.ImageGetter to insert images into spanned HTML.

When I run the app on Android Emulator (Lollipop, it renders fine. Running the app on my phone KitKat causes (may a times) images to overlap (and hide text).

Going through docs, I didn't find any such reference in the changelog. So what could be the reason?

I have tried Android ImageGetter images overlapping text, but this doesn't seem to work.

Call:

contentTV.setText(Html.fromHtml(content, new Html.ImageGetter() {
        @Override
        public Drawable getDrawable(String source) {

            inlineImagesCount++;
            HttpGetDrawableTaskAsync httpGetDrawableTaskAsync = new HttpGetDrawableTaskAsync(
                    contentTV, content);
            httpGetDrawableTaskAsync.execute(source);
            return null;
        }
    }, null));

Rendering code:

protected void onPostExecute(final Pair<String, ByteArrayOutputStream> result) {
            if (result.getSecond() != null) {
                if (inlineImagesMap.get(result.getFirst()) == null)
                    inlineImagesMap.put(result.getFirst(), result.getSecond());
                taskTextView.setText(Html.fromHtml(taskHtmlString,
                        new Html.ImageGetter() {
                            @Override
                            public Drawable getDrawable(String source) {
                                Drawable inlineImage = expandBAOStoDrawable(inlineImagesMap.get(source));
                                return inlineImage;
                            }
                        }, null));
            }

            if (--inlineImagesCount == 0) {
                freeInlineImagesMap();
            }
        }

Example: Left-Kitkat, Right- Lollipop (The two images for each are scrolled to show full content) The HTML it rendered is here. Left-Kitkat, Right-Lollipop

xyz
  • 3,349
  • 1
  • 23
  • 29
  • You might consider taking some screenshots. You may not have the rep here to be able to post them, but you can upload them elsewhere and link to them from your question. Beyond that, you might want to post some sample HTML that is generating these results. – CommonsWare Jun 01 '15 at 23:23
  • Well, for something of this size and complexity, I would recommend a `WebView`. Beyond that, since we still don't know the HTML that you are using here, I don't know what would be causing the problem. – CommonsWare Jun 02 '15 at 11:23
  • I added the HTML, and you are correct, I switched to a `WebView` and the performance is insane! However, I require `LayoutAlgorithm.TEXT_AUTOSIZING` for the `WebView`, which is API Level 19. So this is a fallback for me. – xyz Jun 02 '15 at 12:24

0 Answers0