I was wondering if there was a way to allow a RecyclerView to scroll even if it does not fill the empty space. For example, in the image below, allow the grid to scroll down so cells '28' and '29' hit the bottom of the screen, leaving an empty space above 1, 2, 3 and 4. I have not been able to find anything on the topic. The RecyclerView I have implemented does not scroll unless the cells go past the bottom of the screen.
Related
[Sliding left takes to next page of results and sliding right takes to prev page of results (of the same search), dashes at the bottom shows the page position please look into the png]
https://i.stack.imgur.com/fyxac.png
If you know the number of elements per screen, you can use LinearLayout and add the elements to it at runtime. You anyway won't be recycling views if there is no scroll.
Even if you don't know the number of elements per screen, the next best thing to would be to calculate the number of elements you can completely fit by dividing the left over screen size by the size of one element.
For horizontal pages, you can make use of ViewPager.
I have a RecyclerView with custom LayoutManager that handles the photo laying out so the result is different in portrait and landscape as you can see in the images below.
Now everything is working fine except for when I handle onConfigurationChanged() callback from portrait to landscape and vice-versa.
I want to save state of recyclerView so when user flips the device I will scroll the recyclerview to the same spot he was before rotating.
If you will notice the photos below, the landscape working fine but when I switch to portrait it does scroll to the last position the user where (notice the red car and it is rationally logical since this is what I wanted) but except for one problem, it looks as if the recyclerview is getting suddenly extra white space at the bottom.
I would like to avoid it and get the recyclerview to the bottom of its content (the red car is not the first item in the data set, I have plenty more before it) without actually taking the user to his last item if the position scrolled to is getting the recyclerview to "expand".
How can I calculate if the scrollToPosition() is "expanding" the recyclerview over its content height ? If I remember correctly it does not happen in LinearLayoutManager or GridLayoutManager.
I only need to know if the position that is laying out has enough space before actually scrolling to it and eventually scrolls to a minimum one that does not gives the white space at the bottom, but I don't know how.
Side note: If I scroll it up and then down again it does stay at the bottom without the extra white space.
I succesfully implemented RecyclerView using StaggeredLayoutManager with 2 col/spans. I have variable heighted items in each col, heights are not fixed.
Problem is, when I scroll down and up in RecyclerView, sometimes a gap is occured at the top item of one of the rows. I added a video describing my problem.
I simply added a StaggeredLayout with span value 2, and adapted my items with an adapter.
+-+-+-+-+-+-+-+-+-+-+-+-+ <------ Top of RecyclerView
-------------- <- Top item in left column
------------- <- Top item in right column, has unexpected gap/offset/margin at top.
Gap sometimes occurs. Sometimes, everything is well aligned and no problems.
Here is the video I take from my application.
https://youtu.be/gmB7h73YR3M
Look at the topmost 2 pictures(LinearLayouts) in the list, cup and monitor. Their top position differs after each scroll down and then up event, and an unwanted grey area (Backgroundcolor of RecyclerView) appears at there.
Between 0-3 sec, there is a gap on top of cup, left column.
Between 7-8, there is a gap but little than 0-3
Between 10-12, everything is fine, their tops are at same level.
Between 19-21, this time right column has a gap on top.
Any reasons why I have this problem, any solutions?
EDIT:
Because I don't want so much moving items, I set gapping strategy as GAP_HANDLING_NONE. However, when I set strategy as GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS, toppest line of two items get aligned when Scrolling Up ends at top. My observation is, when scrolling to the elements at top, a last calculation is made to Align top lines of 2 items if strategy is GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS, but not in GAP_HANDLING_NONE. I can see it is aligned with my eyes, but it doesn't seem to happen when strategy is GAP_HANDLING_NONE.
Here's the idea: I have some ScrollView, e.g. with 10 elements, say buttons.
Only 5 are visible at the time.
By default, if I swipe up a little bit (30% of next element's height), app will show me 30% of 6th item, and hide 30% of 1st item at the top.
I would like to customize this behavior, so that it pulls up a new element from below only after I've swiped up for more than a half of that elements height.
If I swipe just a little, it disregards scrolling and hides back the element that could've been shown if I swiped more.
Sadly, I can't remember an app to point as an example. The nearest is pulling NavigationDrawer (or sliding home screens in your launcher): if you slide only a little and release - it hides everything back.
Additionally, I would animate showing that new element (e.g. scaling from 0 to 100) and hiding the one on top that is being hid (scaling from 100 to 0). But that's second issue, I'd rather think of it when I deal with this threshold of scrolling.
Has anyone heard about some kind of library for this? I would expect that to be in API, but it's not there, AFAIK.
I want to represent a DataBase output to a GridView, the deal is that I want this GridView scroll horizontally and vertically. The reason for that is that I may have a table that has a number of columns that will not fit on screen, So Horizontal scrolling is necessary.
Now for vertical scrolling: I may have a big DataBase (with 100 entries and more...) So I do want it to scroll vertically as well and use the View recycling mechanism to populate the GridView (for the Vertical Scrolling, no View recycling is needed for the Horizontal Scrolling).
I have already stumbled on this solution:
https://gist.github.com/codeswimmer/869685
But I have few problems with this:
1. It uses a deprecate Gallary View.
2. I think this changes the vertical scrolling to a horizontal one but doesn't allow both of them.
Is this even possible?
Any direction on this topic would be really appreciated.