RecyclerView scrollbar jumps back to top after first item


Marc Dong
20/11/2014 1:20 pm
HOME ยป Web Development

I created a very basic RecyclerView example.

Layout:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MyActivity">

    <android.support.v7.widget.RecyclerView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="vertical"/>

</RelativeLayout>

Activity:

public class MyActivity extends Activity {

    RecyclerView mRecyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my);

        mRecyclerView = (RecyclerView)
findViewById(R.id.recyclerView);
        mRecyclerView.setAdapter(new TestAdapter());
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    }

    public static class TestAdapter extends
RecyclerView.Adapter<TestAdapter.ViewHolder> {
        @Override
        public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int
i) {
            View view =
LayoutInflater.from(viewGroup.getContext()).inflate(android.R.layout.simple_list_item_1,
viewGroup, false);
            return new ViewHolder(view);
        }

        @Override
        public void onBindViewHolder(ViewHolder viewHolder, int i) {
            viewHolder.tv.setText("Row " + (i + 1));
        }

        @Override
        public int getItemCount() {
            return 30;
        }

        public static class ViewHolder extends RecyclerView.ViewHolder
{

            TextView tv;

            public ViewHolder(View itemView) {
                super(itemView);
                tv = (TextView)
itemView.findViewById(android.R.id.text1);
            }
        }
    }
}

Now when I scroll beyond the first item, the scrollbar jumps back to the top and then continues normally. The second problem is when I scroll to the bottom, the scrollbar stops to early. Is this a bug in the support lib or my own fault?


Related to : RecyclerView scrollbar jumps back to top after first item
RecyclerView scrollbar jumps back to top after first item
20/11/2014 1:20 pm by Marc Dong in Web Development

I created a very basic RecyclerView example.

Layout:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools
RecyclerView: no scrollbar
25/12/2014 3:00 am by PsyberMonkey in Web Development

I've got a RecyclerView and would like to have scrollbar showing, when it covers more than one page.

I get no scrollbar at all. Any idea?

My layout:

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"

Add a new item to recyclerview programatically?
8/1/2015 4:40 pm by zclin in Web Development

I'm still trying to get my head around recyclerview. I have an arraylist, that I use to initialize a recycler view with.

How can I add new items to the recycler view post setting an adapter and layoutmanager?

private void initData() {
        mItems = new ArrayList<Str
RecyclerView Animation on Item Click
31/12/2014 7:10 am by DCal430 in Web Development

I am trying to implement my own recyclerview Animation - I would like to achieve this without using any external libraries. Here is what the theoretical animation should look like.

enter image
description here

The user


How to properly highlight selected item on RecyclerView?
2/12/2014 2:20 am by Brian in Web Development

I am trying to use RecyclerView as horizontal listview. I am trying to figure out how to highlight selected item. When i click one of the item, it gets selected and it is highlited properly but when i click another one second one gets highlighted with the older one.

Here is my onClick fu


Implement Swipe Gesture on a RecyclerView Item?
14/11/2014 1:10 am by Kbotei in Web Development

I have seen nice solutions to implement onClick and onLongClick gesture in OnItemTouchListener. What I am looking for now is the code to implement a Swipe Gesture in OnItemTouchListener.

If you have any idea or if you came across a blog or a tutorial , please let me know.Thanks.


How to click on an item inside a RecyclerView in Espresso
15/12/2014 8:30 am by DaveStall in Web Development

I have a RecyclerView (R.id.recyclerView) where each row has an image (R.id.row_image) and a textview. I want to click on the image. I want to click on the image in the first row.
I've tried to use onData(..) but it doesn't seem to work.


Change the margin of first visible item in recyclerview
7/5/2016 5:43 am by greggerz in Web Development

How to change the margin (bottom with 20 dp) of first complete visible item on horizontal recycleview with cards? I can get only the index of first complete visible item but not any reference to the view.

`mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {


Android Robolectric Click RecyclerView Item
21/11/2014 1:50 am by ArmHead in Web Development

Is there any way to simulate a click on a RecyclerView item with Robolectric?

So far, I have tried getting the View at the first visible position of the RecyclerView, but that is always null. It's getChildCount() keeps retu


Highlight selected item inside a RecyclerView
9/12/2014 11:20 pm by surfsatwerk in Web Development

I'm having trouble with highlighted an item within a RecyclerView, similar to setting the selected item in a ListView.

At the moment, I've set up up the RecyclerView, have a default LayoutManager, and have an adapter which displays all the data. I've just recently got the onClickLis


Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2014 © bighow.org All Rights Reserved .