android-recyclerview
Scrollbar color in RecyclerView
You can do this by including following line of code in your Recyclerview android:scrollbarThumbVertical=”@drawable/yoursdrawablefile The drawable file in my case is: <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android”> <gradient android:startColor=”#000″ android:endColor=”#000″ android:angle=”45″/> <corners android:radius=”6dp” /> </shape>
Disable animation on notifyItemRangeInserted()
try clearing the RecyclerView item animator recyclerView.setItemAnimator(null); you can re-enable your animation after if needed. recyclerView.setItemAnimator(null); notifyItemRangeInserted(int positionStart, int itemCount); recyclerView.setItemAnimator(new DefaultItemAnimator());
Android – Detect when the last item in a RecyclerView is visible
You can create a callback in your adapter which will send a message to your activity/fragment every time when the last item is visible. For example, you can implement this idea in onBindViewHolder method @Override public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { if(position==(getItemCount()-1)){ // here goes some code // callback.sendMessage(Message); } //do the rest of …
Setting span size of single row in StaggeredGridLayoutManager
You can use the setFullSpan method. In this way the item will layout using all span area. That means, if orientation is vertical, the view will have full width; if orientation is horizontal, the view will have full height. Something like this: public final void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) viewHolder.itemView.getLayoutParams(); …