I have a RecyclerView in which I add items regularly. I want the background of the RecyclerView to expand while the list of items grows.
For example, if the list has two items and a new one is added, a new part of the background is discovered, and so on...
What I expect
The complete RecyclerView is as in the image below. The user can only see a part of it, but discovers the rest when he/she scrolls up or down (which is why RecyclerView exists, I believe).
Here we can see that the whole background is actually expanding beyond the screen's top and bottom border. So whenever the user scrolls the RecyclerView, the background moves with it (matching the movements of the list).
I'm completely lost with that, do you have any idea how to achieve such a behavior?
Related
I am a beginner, and i tried to find an answer but everything i found was from 2013 and earlier. I want to create a grid which you can scroll in any direction, (as a zoomed in picture), which contains items of different sizes which are generated randomly, then i want to populate them with a recycler view. I will attach an illustration, maybe you would understand it better.As you can see, the thick outline is the phone screen and whenever you scroll the view, it generates new items which are populated by a recycler view.
I thought of using Google's FlexBox Layout for generating the items but i don't really know how to create that scrollable view. I would literally pay to get this done.
I don't think you can make RecyclerView scroll in Both way. U can Create Nested RecyclerView if that is what you are looking for.
What I mean is, I want it to be so that each item in the recyclerview is fully transparent, showing the element behind the reyclerview. At the same time, the parts of RecyclerView which do not have a child element, I want them to be black. Is that possible?
Not quite sure of your design requirements as per your description, however you should be able to set the transparency of both the RecyclerView and each rows view via android:background="#00000000"
I'm new to android development
I have a Recyclerview and I want it to always show items with full layout not part of the item when screen size is changed!
say I have a Recyclerview that shows 3 items vertically in XXXhdpi when I changed the device with smaller screen (for example the new device's screen size is XXhdpi) the recyclerview shows 2 items and part of the 3rd Item and you have to scroll to see the whole item...
how to avoid this problem and always show the 3 items or maybe 2 items ! what i care about is to always show the whole item that fits in the screen not part of it.
if the screen can fit 2 items then the 3rd item should not be showed and the 2 items that appear should have bigger width and height to fit in the screen and hide the space of the 3rd item.
Thank you.
Let's say single_row.xml is the layout that is repeated in the recylcerview
You will have to create separate single_row.xml layouts for various screen sizes. And they will be accordingly used during the onCreateViewHolder
Essentially what I want to happen is, after the user scrolls the list, I want the elements to snap into 'grids' instead of remaining where they are, so that I can center the middle component in the list, like in the picture.
I tried manually changing the setSelectedIndex after setting ScrollToSelected to true, but that lacks any animation, and the list scrolls the element to the edge of the screen, rather than the middle.
How can I have the effect of scrolling the element with animation, and to the middle of the screen?
LWUIT & Codename One both have a snap to grid property in Container and in List. Did you activate it? Just use setSnapToGrid(true) on any component.
Is it possible to make a background stretch over the whole ListView, instead of just staying on a fixed position?
I remember in CSS when making websites you could make the background-attachment fixed for a background to stay the same place when scrolling, I am trying to archive the opposite of this, making the background follow the data when you scroll down. Is there such a thing for ListView?
Using a stock ListView to do what you want would not be possible.
ListView only displays a few rows at a time in order to save on View creation/management/etc. that could bog the system down. As a result, the ListView doesn't even know the total height of itself - it doesn't render a row until that row is visible, and rows can vary in height. If it doesn't even know its own height, how could it have a background that spans the entirety of it?
That said, your idea of using a ScrollView would be possible. However, you would then be losing out on ListView's optimization - if you only had few rows, then this isn't a big deal; but if you're talking about dozens of rows (or more), then your app may seriously chug. Also, you don't get ListView's framework, which is geared towards making an easier row-based UI.
It would be possible to write your own ListView subclass (or custom ListView) that can calculate its total height (so long as you know that each row is of a fixed height), then draw the background accordingly. That is probably what I'd do if I was required to do what you describe and had too many rows to just stuff into a ScrollView comfortably.