0

I'm beginner in Android Development and trying to create a display of items in such a way that the size of these varieties according to the quantity, as they have done in this app. Any suggestions?

Screenshot 1

Screenshot 2

Waqar UlHaq
  • 6,144
  • 2
  • 34
  • 42
vx00
  • 66
  • 1
  • 6

2 Answers2

0
LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager​.​HORIZONTAL​, false);

RecyclerView myList = (RecyclerView) findViewById​(​R​.​id​.​my_recycler_view​);

myList​.​setLayoutManager​(​layoutManager​);
Bad Boy
  • 381
  • 2
  • 14
Durai
  • 59
  • 6
0

So according to your question you have to add weight to the child elements which you can be given from parent layout like ex: recyclerview weight 3, and its item weight 1 each(if you have 3 items and fit in the width with margins on either sides) and consider to assign 3 to 6 elements in the width of the screen with horizontal scrolling

mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, true));

check here how to set weights for the views How to set layout_weight attribute dynamically from code?

Prakash Reddy
  • 944
  • 10
  • 20