androidandroid-layouthorizontal-scrollinghorizontallist

Horizontal Slider for shopping app


Am working on a shopping app and want to implement the Horizontal Slider/Pager as shown in the screenshot.

shopping app

After a brief search found that I can use:

Please Suggest the best Layout i can use for this. OR Suggest a better way to implement this if you have already worked on such Views.

Thanks.


Solution

  • I have recently develop horizontal scrolling view using RecyclerView with a LinearLayoutManager. I used to do it using an Horizontal Scroll View with a linear layout inside but I never was a big fan of this approach.

    I liked the RecyclerView approach because it work really like ListView and allow you to implement ViewHolder pattern. You have to set a RecyclerView.Adapter instead of a classical Adapter.

    You can follow the example here

    https://developer.android.com/training/material/lists-cards.html

    To make the recycler view horizontal you have to set its layout manager with horizontal orientation :

    layoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
    mRecycler.setLayoutManager(mLayoutManager);