0

i have issue is that i wanna to creat table in landscape mode while the activity in portrait mode so i think that i can make it with rotated recyclerView XML here

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:rotation="90"
        android:background="@color/colorPrimary"
        tools:layout_editor_absoluteX="8dp" />

and java

        DisplayMetrics displayMetrics = new DisplayMetrics();
        getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        int height = displayMetrics.heightPixels;
        int width = displayMetrics.widthPixels;
        recyclerView.setLayoutParams(new FrameLayout.LayoutParams(height, width));

so in the case i have rotated recyclerView but isn't in ther place

2 Answers2

1

If you want a horizontal recyclerView in your layout you just have to set the layout manager as LinearLayoutManager and the second parameter to LinearLayoutManager.HORIZONTAL:

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

This will result in a recyclerView that is horizontaly scrollable in a vertical layout.

Joel Bodenmann
  • 2,152
  • 2
  • 17
  • 44
0

The answer on the link below should help you achieve your goal if am getting you right.

Is it possible to write vertically in a text view in android?

Use the same trick to get your effect. Just replace the textView with your recycler view

Happy coding.

Piper2
  • 299
  • 2
  • 10
  • The answer in the link you have provided explains it better... In which case I presume it is going to be a lot of work for you to manipulate it... I have tried the solution in a sample application and my solution works but it would take a lot more work to handle the events afterwords as he sites above – Piper2 Dec 22 '19 at 14:03