I have a requirement in which there will be multiple child items to a RecycylerView Item. As per the requirement a single recycler view item can have maximum of four horizontal Childs and 2 vertical Childs at max. I have used recyclerview inside a recyclerview to achieve this by the results are not per the requirement. In short I need something like this
The results of recyclerview inside recyclerview is something like this. The items are not stretching to full length as highlighted in yellow.
How can I achieve this? I have user grid layout manager on inner recyclerview with spancount of 3 and tried with 4 as well. Converted to linearlayout manger horizontal but not able to get the desired result.
You can use GridLayoutManager for this. Just call the setSpanSizeLookup method and determine how many columns an item should take.
Related
I'm trying to achieve a design for recycler view in grid layout style. Any Input towards achieving it is very helpful.
I have to design for span size 2 only.
Design :
I tried to use GridLayoutManager with span size 2
If you mean that list should scroll horizontally and each next column should be following of previous one. I think you can done it by horizontal recycler view with items that contain two views and top space margin which increases sequentially.
Height of the RecyclerView should be calculated and set by last column in code.
I am using a recyclerView, with a GridLayoutManager layout.
The recycler view contains 2 types on ViewHolders, one having span size equal to 3 in order to separate different types of grid elements and one of size equal to one.
What i want is to be able to hold always on the top one of the view holders of the size 3 (depending on the horizontal scroll position), like shown in the image below.
Does anyone has any idea how to do it? If it is possible i would want to avoid to create a custom layout, is there an easier way to do it?
grid layout exemple
You can check this github project
StickyHeaders
You can use directly this and import it as a dependency or you can look at the code and try to implement your own "sticky" header.
Let's say I have 100 rows of data to show in a ListView. So far no problem. I have a custom adapter for each row, that has a TextView for a date, a TextView for a sequence number and NOW 60 more TextViews, mostly having a two digit number.
How can I get a horizontal scroll to show all these 60 numbers, BUT, the vertical scroll for the Listview should still work, to scroll down from 1 to 100 row, and also, all rows shown on the screen shall scroll horizontal at the same time, not that only one row will scroll horizontal.
Had tried TwoWayView, but only allows to define one direction of scroll.
You need to have a horizontal scrolling list as each ListItem. Although, there are several horizontal scrolling view options, I would recommend using a Recyclerview with a LinearLayoutManager and orientation set to HORIZONTAL.
The general idea is you need a horizontal list as a list item.
I want to achieve a specific pattern with a RecyclerView list by displaying a dynamic contact list based only on a single CardView.
The contact list can have several items in it. Like over 100. Every contact should be a single item and of course, all the area should be scrollable.
A solution would be to make a non-scrollabe ListView but the scroll would not be fluid as there are many items in the list.
Another solution would be to create a custom CardView item for the top, the middle and the bottom or even overlap all the CardView items with a negative margin.
I am wondering if there are some better solutions working with the RecyclerView?
I would try to use a nested recycler and intercept (steal) touch events with the child in the area it's in.
I am trying to make a horizontally scrolling grid. It has two rows. The second row is offset (by half the width of one item, but that is trivial to calculate and doesn't matter here).
I am currently using RecyclerView and the GridLayoutManager from https://github.com/antoniolg/RecyclerViewExtensions/tree/master/library/src/main/java/com/antonioleiva/recyclerviewextensions
However, the offsetting is proving extremely difficult.
It should end up looking like
Does anybody have any suggestions for making the second row staggered like in the picture above?
Use StaggeredGridLayoutManager with an ItemDecoration which adds the offset to the item at adapter position 0. You'll get the desired output. (via getItemOffsets).
Alternatively, instead of an ItemDecoration, when onBind is called, you can set the first item's width such that it will include gap on left.
If your data set changes, don't call notifyDataSetChanged which will reset the historical calculations in SGLM. Instead, use detailed notify events like notifyItemRangeInserted so that SGLM will be able to recalculate layout without resetting positions.
I don't know if you're still working on this, but my approach would be to render the items 2 at a time (top/bottom) with the appropriate offset, and then play with your horizontal margins (set them to negative) to create the overlap between item 2 and 3, etc.
You would have to tie OnTouchListeners to the individual items being rendered, not the RecyclerView entries.