Horizontal and vertical scrolling in Android receiver view mode

I have a requirement when I need to have horizontal scrolling and vertical scrolling in recycler mode. It is based on the type of data coming from the server. If the response from the server has the first element in the form of an array, I need it to be in the horizontal scroll list, and if the second element is the only object, then I need to show it in the card. Similarly, the order changes and should reflect in the user interface. How can i achieve this.

+5
source share
1 answer

LayoutManager is a class that displays layouts in a RecyclerView . So change the recyclerView.setLayoutManager(LayoutManager) if you want to change the layout. In your case, if you are using LinearLayoutManager , do this by calling:

 LinearLayoutManager layoutManager = ... recyclerView.setLayoutManager(layoutManager); //when you want horizontal layoutManager.setOrientation(context,LinearLayoutManager.HORIZONTAL,false); //when you want vertical layoutManager.setOrientation(context,LinearLayoutManager.VERTICAL,false); 
+16
source

All Articles