Search code examples
android-recyclerviewhorizontal-scrollinglinearlayoutmanager

how to make recyclerview slide horizontal


i made a recycleview that works just fine and gets the data and show it but i want that instead of vertical scroll it will be horizontal scroll. i searched and read that to control the scroll orientation behavior i need to use the LinearLayoutManager and set it like this:

      LinearLayoutManager mLayoutManager = new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false);

       recyleview.setLayoutManager(mLayoutManager);

but it dosent work and i dont know why all the examples i saw are with this at the core

anyone have any idea why?\

thanks for any help :)


Solution

  • it was about this line:

         LinearLayoutManager mLayoutManager = new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false);   
    

    but since i tried a couple of tutorials i had this line somewhere else in my code that i forgot to delete it. the problem it was set with .VERTICAL so when it run the code with .HORIZONTAL was running just fine but because later in the adapter initialize i had the same line but with .VERTICAL so it just overwrite the .HORIZONTAL

    so in conclusion just make sure you have ONE LinearLayoutManager initialize at a time :D