I created a very simple RecyclerView example.
Markup:
<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 go beyond the first element, the scrollbar returns to the top, and then continues normally. The second problem is when I scroll to the bottom, the scrollbar stops before starting. Is this a bug in lib or my own mistake?
android android-recyclerview
Kuno
source share