TableView icon indicating copy to clipboard operation
TableView copied to clipboard

display from the right of RecyclerView

Open mahramane opened this issue 4 years ago • 13 comments

Is it possible to display from the right? Help me please. It is very necessary

mahramane avatar Mar 21 '20 14:03 mahramane

I may help if you can give me more details about what you want to do.

brkckr avatar Mar 21 '20 15:03 brkckr

i use android:layoutDirection="rtl"

I want to show the horizontal scrollbar recyclerView from the right for the first time.

mahramane avatar Mar 21 '20 16:03 mahramane

photo_2020-03-21_21-58-21

mahramane avatar Mar 21 '20 17:03 mahramane

As far as I understand, you want RecyclerView to scroll right on the first boot.

manager.smoothScrollToPosition(rvClub, null,0);

manager : FixedGridLayoutManager manager; rvClub : your RecyclerView.

state and the position are not important at this time. keep it null and 0.

brkckr avatar Mar 21 '20 18:03 brkckr

Unfortunately it didn't work 😢

mahramane avatar Mar 21 '20 18:03 mahramane

Then I have no other solution or idea. Good luck. Please let me know when you find the answer.

brkckr avatar Mar 21 '20 19:03 brkckr

Hi How can I use scrollHorizontallyBy in the FixedGridLayoutManager?

mahramane avatar Mar 22 '20 13:03 mahramane

The parameter dx means the change in x coordinate. In your case, you want to move it in the opposite direction. which means dx must be a negative value. But I have no idea about other parameters of scrollHorizontallyBy.

Still, I am not sure if you use manager.smoothScrollToPosition(rvClub, null,0) correctly.

 /**
     * Handles RecyclerView for the action
     */
    private void setUpRecyclerView()
    {
        clubAdapter = new ClubAdapter(MainActivity.this, clubList);

        FixedGridLayoutManager manager = new FixedGridLayoutManager();
        manager.setTotalColumnCount(1);
        rvClub.setLayoutManager(manager);
        rvClub.setAdapter(clubAdapter);
        rvClub.addItemDecoration(new DividerItemDecoration(MainActivity.this, DividerItemDecoration.VERTICAL));


        manager.smoothScrollToPosition(rvClub, null, 0);
    }

I got the following result from physical device, operating system Android 9.

ezgif-3-275bb0cd79b1

brkckr avatar Mar 22 '20 15:03 brkckr

Did you tried setReverseLayout(true) ? https://stackoverflow.com/questions/31728837/recyclerview-grow-element-from-right-to-left

monsterbrain avatar May 15 '20 12:05 monsterbrain

Hi, Could you please help me out? I am trying to add views dynamically (not fixed in size) for each recycler view item, but the problem is after adding views, it's not scrolling horizontally. Attached screenshot for reference Scroll_issue .

SaggamAnand avatar Feb 12 '22 15:02 SaggamAnand

Hi,

Can you give 200dp width to each element you add to the row of the RecyclerView and tell me if it works? The width of each row of the RecyclerView must be wrap_content.

Do you have the 16th, 17th or 20th element in each row?

brkckr avatar Feb 12 '22 19:02 brkckr

Hi, I tried to set a fixed height/width for the row item element, but still, it is not getting scroll. It gets scrolled when we have fixed views in each item of recycler view.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/score_text_view"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_centerInParent="true"
        android:gravity="center"
        android:textColor="@color/colorPrimaryDark" />

</RelativeLayout>

SaggamAnand avatar Feb 14 '22 07:02 SaggamAnand

Then I have no other solution. Hope you can solve it.

brkckr avatar Feb 14 '22 15:02 brkckr