Questions tagged [linearlayoutmanager]

A RecyclerView.LayoutManager implementation which provides similar functionality to ListView. It was introduced with the Android L Developer Preview along with RecyclerView, but is also available as part of the Support Library.

LinearLayoutManager is an implementation of RecyclerView.LayoutManager which provides similar functionality to ListView, i.e., it arranges items in a linear arrangement, either horizontal or vertical, much like LinearLayout ViewGroup. It was introduced with the Android L Developer Preview along with RecyclerView, but is also available as part of the Support Library.

Official Documentation

Other RecyclerView.LayoutManager implementations:

160 questions
4
votes
0 answers

Custom Linear Layout Manager add an empty card to recyclerView

I am using recycler view to display list of cards in my android app. Earlier i was using LinearLayoutManager to set layout manager for recycler view. But using this wrapcontent value for height tag of recycler view was not working and it covered…
Aditya Verma
  • 91
  • 1
  • 10
3
votes
1 answer

Prefetching view for child recycler view is not working

I have vertical RecyclerView with child(nested) horizontal RecyclerView. For second recycler I use layout manager: LinearLayoutManager(itemView.context, LinearLayoutManager.HORIZONTAL, false).apply { isItemPrefetchEnabled = true …
andreich
  • 830
  • 1
  • 9
  • 25
3
votes
4 answers

LinearLayoutManager smooth scroll jumps to wrong position

I'm am trying to make a layout similar to how Instagram's filter layout works. Basically when you select a filter it will scroll to the item you selected + 1 showing you that there are more filters. I currently am trying to build a custom…
Nick
  • 8,824
  • 32
  • 98
  • 143
3
votes
2 answers

Check whether a RecyclerView needs to scroll

I have a callback that is fired after a programmatic scroll to a certain item of a RecyclerView via LinearLayoutManager.smoothScrollToPosition(). The user taps on an item and the right item is scrolled to the top of the RecyclerView. I subclassed…
Micky
  • 5,411
  • 7
  • 26
  • 54
3
votes
2 answers

One LinearLayoutManager is only for one RecyclerView?

I am building an app having three RecyclerView in one fragment to show horizontal list of items. i created a LinearLayoutManager object and set it to all three RecyclerView . but it crashes app, saying one LinearLayoutManager can attached to only…
Adnan Ali
  • 752
  • 1
  • 8
  • 20
3
votes
2 answers

Change LayoutManager depending on device format

I have a RecyclerView with a list of Cards. I want to know whether it's possible to change the RecyclerView's LayoutManager to Linear, when using a phone, and StaggeredGrid, when using a tablet, programmatically. My initial idea was to have the…
2
votes
0 answers

RecyclerView not scrolling top top when new item inserted

I have a RecyclerView which allows swipe-to-delete functionality. After deliting, a Snackbar shows to confirm deletion with an action that allows users to "undo" the delete. Everything works fine until I delete the item at position 0 then hit undo.…
Muzzle
  • 183
  • 8
2
votes
0 answers

Item insertion animation is all wrong in reversed stackFromEnd RecyclerView

My code looks like this, I am setting my layoutManager in onAttachedToRecyclerView of my Adapter. class ChatsAdapter(messages:List): RecyclerView.Adapter{ init { setHasStableIds(true) } override fun…
Rishabh876
  • 1,971
  • 1
  • 14
  • 31
2
votes
2 answers

how to fix RecyclerView.setLayoutManager NullPointerException in fragment

Error: process: tifawt.com.yourschool, PID: 8372 java.lang.RuntimeException: Unable to start activity ComponentInfo{tifawt.com.yourschool/tifawt.com.yourschool.activities.main_activity}: java.lang.NullPointerException: Attempt to…
2
votes
0 answers

RecyclerView smoothScrollToPosition(lastItem) scrolls to bottom where last item is partially visible

Im working on chat type screen where new text msg item is added in list and recyclerView is scrolled to last position of the list but the last item is partially visible, and does not scroll till end of bottom when the keyboard is open. I have added …
2
votes
0 answers

infinity recyclerview for fixed count of items

I need something like this: After last element of my recyclerview should be first element, and vice versa. For example: View2, View3, View4, View1, View2, View3, View4, View1, View2... and so on. EDIT ok, this is part of adapter: @Override public…
2
votes
3 answers

LinearLayoutManager.findViewByPosition() is returning null

My Activity is showing a RecyclerView with a LinearLayoutManager. I want to get the first item (View) in the list. According this post's accepted answer , I can do it calling LinearLayoutManager.findViewByPosition() method, but I'm getting null…
Héctor
  • 19,875
  • 26
  • 98
  • 200
2
votes
3 answers

Snap Recyclerview item to Center when loaded

I am using an infinite scroll for recyclerview with X items which repeats. Also i want am using PagerSnapHelper() to snap the scroll like viewpager. So initially when the list is loaded the display is like - As soon as i start scrolling on either…
2
votes
1 answer

Recycler View linear layout manager returning null

I have a recycler view which contains multiple items and each item in the recycler view contains a horizontal recycler view.The problem I am encountering is that the layout manager is null. java.lang.NullPointerException: Attempt to invoke virtual…
Jude Fernandes
  • 6,969
  • 9
  • 43
  • 82
2
votes
3 answers

Smooth Scroll Not Working on Initial Scroll for Android RecyclerView

I am working on an Android app that runs on only one devicerunning KitKat. The smooth scrolling feature for a RecylerView I used that was working on other physical tablets and genymotion has unfortunately stopped working on the one device it needs…
1 2
3
10 11