I am developing a chat app, and when I open a chat with images (that I am loading using Fresco), it scrolls automatically. Initially, I was using Picasso for loading image, but I tried changing it with other libraries, but the issue remained same. Can anyone guide me what could be the issue or what is the right direction to fix the issue?
Asked
Active
Viewed 684 times
2
-
Are you sure this is related to Fresco? Just try to remove image inflating (don't set image url) and if you have the same issue. – Ihor Bykov Oct 10 '18 at 19:11
-
I also was working and chat implementation and used Fresco. I never faced this issue – Ihor Bykov Oct 10 '18 at 19:11
-
no this is not related to fresco – zohaib khaliq Oct 10 '18 at 19:23
-
@zohad check in your code where you call `scrollToPosition` – Ihor Bykov Oct 10 '18 at 19:24
-
here is the full adapter code https://gist.github.com/khaliqzohaib92/a5a27243087aa307d725e4d41d83990d – zohaib khaliq Oct 10 '18 at 19:26
-
Not in adapter, Do you interact with Layout manager to scroll? – Ihor Bykov Oct 10 '18 at 19:27
-
no i am using this to scroll recyclerView_messenger_messages.scrollToPosition(messengerAdapter.getItemCount()-1); – zohaib khaliq Oct 10 '18 at 19:28
-
When you do you call it? – Ihor Bykov Oct 10 '18 at 19:30
-
every thing was working fine. Until i added the attachment support for images in the app. – zohaib khaliq Oct 10 '18 at 19:30
-
after adding all the images in the reyclerview – zohaib khaliq Oct 10 '18 at 19:31
-
Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/181634/discussion-between-zohaib-khaliq-and-igor-bykov). – zohaib khaliq Oct 10 '18 at 19:33
-
Did you get any solution? – Krupa Kakkad Aug 02 '21 at 05:21
3 Answers
0
Try this call
recyclerView.scrollToPosition(yourListMessages.size() - 1);
It will set to bottom of your list of messages

Abner Escócio
- 2,697
- 2
- 17
- 36
-1
To avoid this issue, either use image placeholders while an image is loading or establish a minimum size for your cell that's close to the size of the image once it's loaded. It looks your cell is re-sized to fit the image when loading is done, causing rest of the content in your recycler view to shift to accommodate new cell size.
Another thing to try is to set a defined height on your ImageView
and use any of the options from android:scaleType
to match how you display an image in your cell based on your needs.

C0D3LIC1OU5
- 8,600
- 2
- 37
- 47
-
-
Well now that you know what the issue is, I am sure you will find a way to deal with it. I have no idea of your business requirements to suggest any more solutions. – C0D3LIC1OU5 Oct 10 '18 at 19:30
-
@zohaibkhaliq If any of these answers helped you, you should upvote/accept it. – C0D3LIC1OU5 Oct 15 '18 at 19:20
-
-
@zohaibkhaliq You should post the solution you found as a separate answer if it's different from any of the answers here. This way people who have the same issues will be able to resolve them, – C0D3LIC1OU5 Oct 15 '18 at 21:27
-1
Delayed the call to scrollToPosition until recycler view item gets loaded.

zohaib khaliq
- 697
- 10
- 17
-
This looks like a workaround. List cells shouldn't resize once an image is loaded. – C0D3LIC1OU5 Oct 16 '18 at 21:10