I have a RecyclerView inside a ScrollView and I want to scroll all of the items in my screen, and I get data from the server. my problem is each item of RecyclerView has a photo, and because of nesting scrolling, recycler assumes that the height of the page is unlimited so it gets all of the items from the server and tries to download all photos, and this makes scrolling not smooth!!
my question is, is there any way to download only shown items photo in RecyclerView? (I know RecyclerView itself does that! but it's not working inside a scrollView)
note :I've also seen similar question like this and this. the first one provides an acceptable solution but requires a lot of change for me! therefor I'm looking for a better solution!
Did you try with Glide? It only load photos when it is visible.
Related
Default RecyclerView feature is to load only those items which are visible and load rest of the items as needed when user scrolls the list.
But my requirement is to load all items at once.
Any idea how to achieve this.
I am loading a Book and each page has multiple images for every line.
I am loading one image per item and I need to implement auto scroll feature for which I need to calculate whole recyclerview height.
I think instead of changing the default behavior of recyclerView if its possible use listView/gridView (until and unless you need StaggardGridView of recyclerView)
Just keep Recyclerview inside NestedScrollView. In simple first all the views regarding recyclerview items, that of cards is set to NestedScrollView and the things goes perfectly.
I have a RecyclerView which contains one screen full of information per record. I want to restrict user to scroll single record at a time and like to visualize it as if user is viewing one page at a time.
The problem is, I have create a layout of full screen size, and can populate it with data as well. But, on scrolling it gives an effect of as if I am scrolling a role, and on fast swap, it jumps multiple records as well.
I was thinking of ViewPager, but as records size can vary, I don't know how to use it
I have no idea how to solve this problem, please help.
There is an alternative option, instead of using a recycler view you can use this library.
https://github.com/castorflex/VerticalViewPager
It's a view pager but it has an adapter that makes it Vertical, so in that way, you'll have that behavior that you want.
How to stop loading of images when recycler view is scrolling and start loading only when scroll is stopped?
A common application feature is to load automatically more items as the user scrolls through the items (aka infinite scroll). This is done by triggering a request for more data once the user crosses a threshold of remaining items before they've hit the end.
The approaches for ListView, GridView and RecyclerView (the successor to ListView) are documented here. Both are similar in code except that the LayoutManager in the RecyclerView needs to be passed in to provide the necessary information to implement infinite scrolling.
Follow this link for more implementation details:
https://guides.codepath.com/android/Endless-Scrolling-with-AdapterViews-and-RecyclerView
The question is slightly unclear, but I'm going to assume that you are talking about loading images into an imageview in recyclerview/listview items.
Answer:
Don't do it by hand. Use a library (like Glide) to load the images for you.
I got a scroll view. I need a list of items inside the scrollview.
I thinking of using a listview and somehow make it display all items and have the scrollview scroll through them.
I think i will run into scrolling problems so my question is, is what i am doing something that is usually done sometimes? if so whats the best way of doing it if not how else should I have a list of items in a scroll view. do I need to create views pro grammatically as I fetch them? it sounds inefficient
So, lets say I've got my activity all set up, and it loads facebook names and users as well as some other things in a layout, and I just add a layout for each facebook user.
So I have a giant scrollview with a row for each user. Essentially a listview.
This can get up to 250 users, which causes a pretty huge loading time.
Now, the issue is, there is a lot to change if I want to convert this into a listview for the built in lazy loading. Is there any way to implement lazyloading into a scrollview?
Using a ListView and Adapter is lazy-loading in a scrollable view. It's the right solution, and it's pretty easy to set up. Doing anything else will just cause you more problems down the road. Take what the SDK gives you instead of trying to implement it yourself.
Maybe you can cache the result from your last loading, and display those first. Then you can slowly refresh each frame.