Recyclerview with both vertical and horizontal scrolling












2















Currently i'm making my apps layout for t.v, the issue i'm facing is i have a recyclerview to show recent activity of user, in mobiles i have shown the recent activity vertically, but in android t.v we have more width then height so i want to show recent activity horizontally i have tried many solution's like



<android.support.v7.widget.RecyclerView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
tools:orientation="horizontal" tools:layoutManager="android.support.v7.widget.LinearLayoutManager" />


but it's still displaying in vertical i dont know why..
I also tried adding the recyclerview in a ScrollView but still not working., maybe i'm declaring LinearLayoutManager in java that's why it's showing in vertical format..



Code of my fragment where i'm inflating the reclerview



View view=inflater.inflate(R.layout.recent_activity_tab1_recycler_view, container, false);
RecyclerView recent_activity_list = (RecyclerView) view.findViewById(R.id.recent_activity_list);
recent_activity_list.setLayoutManager(new LinearLayoutManager(getActivity()));









share|improve this question





























    2















    Currently i'm making my apps layout for t.v, the issue i'm facing is i have a recyclerview to show recent activity of user, in mobiles i have shown the recent activity vertically, but in android t.v we have more width then height so i want to show recent activity horizontally i have tried many solution's like



    <android.support.v7.widget.RecyclerView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    tools:orientation="horizontal" tools:layoutManager="android.support.v7.widget.LinearLayoutManager" />


    but it's still displaying in vertical i dont know why..
    I also tried adding the recyclerview in a ScrollView but still not working., maybe i'm declaring LinearLayoutManager in java that's why it's showing in vertical format..



    Code of my fragment where i'm inflating the reclerview



    View view=inflater.inflate(R.layout.recent_activity_tab1_recycler_view, container, false);
    RecyclerView recent_activity_list = (RecyclerView) view.findViewById(R.id.recent_activity_list);
    recent_activity_list.setLayoutManager(new LinearLayoutManager(getActivity()));









    share|improve this question



























      2












      2








      2








      Currently i'm making my apps layout for t.v, the issue i'm facing is i have a recyclerview to show recent activity of user, in mobiles i have shown the recent activity vertically, but in android t.v we have more width then height so i want to show recent activity horizontally i have tried many solution's like



      <android.support.v7.widget.RecyclerView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:orientation="horizontal"
      tools:orientation="horizontal" tools:layoutManager="android.support.v7.widget.LinearLayoutManager" />


      but it's still displaying in vertical i dont know why..
      I also tried adding the recyclerview in a ScrollView but still not working., maybe i'm declaring LinearLayoutManager in java that's why it's showing in vertical format..



      Code of my fragment where i'm inflating the reclerview



      View view=inflater.inflate(R.layout.recent_activity_tab1_recycler_view, container, false);
      RecyclerView recent_activity_list = (RecyclerView) view.findViewById(R.id.recent_activity_list);
      recent_activity_list.setLayoutManager(new LinearLayoutManager(getActivity()));









      share|improve this question
















      Currently i'm making my apps layout for t.v, the issue i'm facing is i have a recyclerview to show recent activity of user, in mobiles i have shown the recent activity vertically, but in android t.v we have more width then height so i want to show recent activity horizontally i have tried many solution's like



      <android.support.v7.widget.RecyclerView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:orientation="horizontal"
      tools:orientation="horizontal" tools:layoutManager="android.support.v7.widget.LinearLayoutManager" />


      but it's still displaying in vertical i dont know why..
      I also tried adding the recyclerview in a ScrollView but still not working., maybe i'm declaring LinearLayoutManager in java that's why it's showing in vertical format..



      Code of my fragment where i'm inflating the reclerview



      View view=inflater.inflate(R.layout.recent_activity_tab1_recycler_view, container, false);
      RecyclerView recent_activity_list = (RecyclerView) view.findViewById(R.id.recent_activity_list);
      recent_activity_list.setLayoutManager(new LinearLayoutManager(getActivity()));






      android android-recyclerview






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 8:56









      Vadim Kotov

      4,37953247




      4,37953247










      asked Nov 13 '18 at 8:50









      shaheryarshaheryar

      204




      204
























          2 Answers
          2






          active

          oldest

          votes


















          0














          try to replace this line



          recent_activity_list.setLayoutManager(new LinearLayoutManager(getActivity()));


          with this line



          recent_activity_list.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));





          share|improve this answer
























          • have tried this too, but it sets the orientation horizontal for mobiles too, i want it vertical for mobiles and horizontal for tv

            – shaheryar
            Nov 13 '18 at 9:02











          • so you have to check first if device is Tv or phone and then use one of the layout[horizontal - vertical] you may find this answer helpful for checking stackoverflow.com/questions/27138838/…

            – Hazem Ashraf
            Nov 13 '18 at 9:06











          • thanks it worked...

            – shaheryar
            Nov 13 '18 at 9:30



















          1














          Don't give orientation there. Instead of that use layout manager for setting orientation of recyclerView.



          For ex.



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


          Here first param is context, second is orientation and third is reverseLayout.



          You can change orientation there.






          share|improve this answer


























          • but if i give orientation horizontal here then my mobile shows recyclerview in horizontal, i want it responsive vertical for mobiles and horizontal for tv

            – shaheryar
            Nov 13 '18 at 9:01











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53277080%2frecyclerview-with-both-vertical-and-horizontal-scrolling%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          try to replace this line



          recent_activity_list.setLayoutManager(new LinearLayoutManager(getActivity()));


          with this line



          recent_activity_list.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));





          share|improve this answer
























          • have tried this too, but it sets the orientation horizontal for mobiles too, i want it vertical for mobiles and horizontal for tv

            – shaheryar
            Nov 13 '18 at 9:02











          • so you have to check first if device is Tv or phone and then use one of the layout[horizontal - vertical] you may find this answer helpful for checking stackoverflow.com/questions/27138838/…

            – Hazem Ashraf
            Nov 13 '18 at 9:06











          • thanks it worked...

            – shaheryar
            Nov 13 '18 at 9:30
















          0














          try to replace this line



          recent_activity_list.setLayoutManager(new LinearLayoutManager(getActivity()));


          with this line



          recent_activity_list.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));





          share|improve this answer
























          • have tried this too, but it sets the orientation horizontal for mobiles too, i want it vertical for mobiles and horizontal for tv

            – shaheryar
            Nov 13 '18 at 9:02











          • so you have to check first if device is Tv or phone and then use one of the layout[horizontal - vertical] you may find this answer helpful for checking stackoverflow.com/questions/27138838/…

            – Hazem Ashraf
            Nov 13 '18 at 9:06











          • thanks it worked...

            – shaheryar
            Nov 13 '18 at 9:30














          0












          0








          0







          try to replace this line



          recent_activity_list.setLayoutManager(new LinearLayoutManager(getActivity()));


          with this line



          recent_activity_list.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));





          share|improve this answer













          try to replace this line



          recent_activity_list.setLayoutManager(new LinearLayoutManager(getActivity()));


          with this line



          recent_activity_list.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 8:56









          Hazem AshrafHazem Ashraf

          574




          574













          • have tried this too, but it sets the orientation horizontal for mobiles too, i want it vertical for mobiles and horizontal for tv

            – shaheryar
            Nov 13 '18 at 9:02











          • so you have to check first if device is Tv or phone and then use one of the layout[horizontal - vertical] you may find this answer helpful for checking stackoverflow.com/questions/27138838/…

            – Hazem Ashraf
            Nov 13 '18 at 9:06











          • thanks it worked...

            – shaheryar
            Nov 13 '18 at 9:30



















          • have tried this too, but it sets the orientation horizontal for mobiles too, i want it vertical for mobiles and horizontal for tv

            – shaheryar
            Nov 13 '18 at 9:02











          • so you have to check first if device is Tv or phone and then use one of the layout[horizontal - vertical] you may find this answer helpful for checking stackoverflow.com/questions/27138838/…

            – Hazem Ashraf
            Nov 13 '18 at 9:06











          • thanks it worked...

            – shaheryar
            Nov 13 '18 at 9:30

















          have tried this too, but it sets the orientation horizontal for mobiles too, i want it vertical for mobiles and horizontal for tv

          – shaheryar
          Nov 13 '18 at 9:02





          have tried this too, but it sets the orientation horizontal for mobiles too, i want it vertical for mobiles and horizontal for tv

          – shaheryar
          Nov 13 '18 at 9:02













          so you have to check first if device is Tv or phone and then use one of the layout[horizontal - vertical] you may find this answer helpful for checking stackoverflow.com/questions/27138838/…

          – Hazem Ashraf
          Nov 13 '18 at 9:06





          so you have to check first if device is Tv or phone and then use one of the layout[horizontal - vertical] you may find this answer helpful for checking stackoverflow.com/questions/27138838/…

          – Hazem Ashraf
          Nov 13 '18 at 9:06













          thanks it worked...

          – shaheryar
          Nov 13 '18 at 9:30





          thanks it worked...

          – shaheryar
          Nov 13 '18 at 9:30













          1














          Don't give orientation there. Instead of that use layout manager for setting orientation of recyclerView.



          For ex.



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


          Here first param is context, second is orientation and third is reverseLayout.



          You can change orientation there.






          share|improve this answer


























          • but if i give orientation horizontal here then my mobile shows recyclerview in horizontal, i want it responsive vertical for mobiles and horizontal for tv

            – shaheryar
            Nov 13 '18 at 9:01
















          1














          Don't give orientation there. Instead of that use layout manager for setting orientation of recyclerView.



          For ex.



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


          Here first param is context, second is orientation and third is reverseLayout.



          You can change orientation there.






          share|improve this answer


























          • but if i give orientation horizontal here then my mobile shows recyclerview in horizontal, i want it responsive vertical for mobiles and horizontal for tv

            – shaheryar
            Nov 13 '18 at 9:01














          1












          1








          1







          Don't give orientation there. Instead of that use layout manager for setting orientation of recyclerView.



          For ex.



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


          Here first param is context, second is orientation and third is reverseLayout.



          You can change orientation there.






          share|improve this answer















          Don't give orientation there. Instead of that use layout manager for setting orientation of recyclerView.



          For ex.



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


          Here first param is context, second is orientation and third is reverseLayout.



          You can change orientation there.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 13 '18 at 8:56









          Vadim Kotov

          4,37953247




          4,37953247










          answered Nov 13 '18 at 8:54









          The90sArtistThe90sArtist

          417




          417













          • but if i give orientation horizontal here then my mobile shows recyclerview in horizontal, i want it responsive vertical for mobiles and horizontal for tv

            – shaheryar
            Nov 13 '18 at 9:01



















          • but if i give orientation horizontal here then my mobile shows recyclerview in horizontal, i want it responsive vertical for mobiles and horizontal for tv

            – shaheryar
            Nov 13 '18 at 9:01

















          but if i give orientation horizontal here then my mobile shows recyclerview in horizontal, i want it responsive vertical for mobiles and horizontal for tv

          – shaheryar
          Nov 13 '18 at 9:01





          but if i give orientation horizontal here then my mobile shows recyclerview in horizontal, i want it responsive vertical for mobiles and horizontal for tv

          – shaheryar
          Nov 13 '18 at 9:01


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53277080%2frecyclerview-with-both-vertical-and-horizontal-scrolling%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Anylogic : not able to use stopDelay()