Skip to content

Instantly share code, notes, and snippets.

@nightbear1009
Created December 16, 2014 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nightbear1009/db88e9eefa3e16549626 to your computer and use it in GitHub Desktop.
Save nightbear1009/db88e9eefa3e16549626 to your computer and use it in GitHub Desktop.
recyclerview get view location
package com.example.ted.parallellistview;
import android.graphics.Canvas;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import de.greenrobot.event.EventBus;
/**
* Created by tedliang on 14/12/16.
*/
public class MyItemDecoration extends RecyclerView.ItemDecoration{
@Override
public void onDraw(Canvas c, RecyclerView parent) {
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
if (parent.getChildPosition(child) % 10 == 0) {
EventBus.getDefault().post(new MyImageView.ChangeYEvent(child.getBottom()));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment