You want to show just 10 items at first and swipe to show more items, The better way is to let your recyclerview's width adaptives 10 items total width, so you can custom a LayoutManager for your horizontal recyclerview, and implement it's onMeasure
method to set the width of the recyclerview.
```
@Override
public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state, int widthSpec,int heightSpec) {
View view = recycler.getViewForPosition(0);
measureChild(view, widthSpec, heightSpec);
//int recyclerViewW = ...;
//int recyclerViewH = ...;
//setMeasuredDimension(recyclerViewW, recyclerViewH);
}
```
By the way, if the items you want to show is not fixed in size, this way is not eligible.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.