question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use image loading within ListView?

See original GitHub issue
  • Markwon version: 4.3.1
  • Glide version: 4.11.0

I have a ListView which items are markwon-powered TextViews. (In fact, items are a bit more complex but it is not the case)

So, it looks like this – two items for two lines of text: image

ListView’s attribute transcriptMode is set to normal, so “The list will automatically scroll to the bottom when a data set change notification is received and only if the last item is already visible on screen” as said in docs.

Let’s check.

Initial status When new item added When keyboard shown
image image image

Everything is fine – ListView stays at its bottom.

But when text contains small square picture(s) (something like emoji) strange things occur.

Initial status When new item added When keyboard shown
image image image

As you can see, ListView is somehow “unpinned” from its bottom position and stopped autoscroll.

I suppose it is somehow related to dimensions of loaded image because “emoji” blinks (dissapears and reappears in a single moment) when new item is added to list.

As for code, I use GlideImagesPlugin in that way:

Markwon.Builder b = Markwon.builder(context)
.usePlugin(MovementMethodPlugin.create(ScrollingMovementMethod.getInstance()));

b.usePlugin(GlideImagesPlugin.create(new GlideImagesPlugin.GlideStore() {

    @NonNull
    @Override
    public RequestBuilder<Drawable> load(@NonNull AsyncDrawable drawable) {
        return Glide.with(context)
                .load(drawable.getDestination())
                .placeholder(emojiPlaceholder)
                .error(emojiPlaceholder)
                .fallback(emojiPlaceholder)
                .override(emojiSide, emojiSide)
                .centerCrop();
    }

    @Override
    public void cancel(@NonNull Target<?> target) {
        Glide.with(context).clear(target);
    }

}));

markwon = b.build();

and when it comes to getView() I just call markwon:

markwon.setMarkdown(message, text);

Expected behavior: listview should stay at its bottom.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
IriaSomobucommented, Aug 3, 2020

@ubuntudroid wrong size: placeholder height is bigger/smaller than size of actual image; proper size: placeholder is exact tall as loaded image;

How it works: when using wrong placeholder, item changes its height after actual image been loaded that forces listview to “unpin” list from bottom of the screen.

0reactions
ubuntudroidcommented, Aug 3, 2020

@iillyyaa2033 could you elaborate? What do you mean by wrong/proper placeholder sizes?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loading images in a Listview properly - Stack Overflow
I'm using the Universal Image Loader library to load images in my listview, it loads the images but I notice that if you...
Read more >
How to Lazy Load Images in Android ListView? - GeeksforGeeks
Step 1: Create a New Project in Android Studio · Step 2: Adding Layout · Step 3: Adding permissions and dependencies · Step...
Read more >
ListView with Images and Text [Scroll With NO Lag] - YouTube
Android Beginner Tutorial #10 - ListView with Images and Text [Scroll With NO Lag]By the end of this video you will know how...
Read more >
How to Load Image From URL in Image List with List View C# ...
Do you find the way to load images from URL without download them into your local drive? Some developer mostly use the way...
Read more >
Load Images From Web to ListView Using Picasso - YouTube
SOURCE CODE REFERENCE : http://camposha.info/source/android-picasso- listview - load - images -online/Browse SOURCE CODE of this and other ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found