Skip to content

Instantly share code, notes, and snippets.

@PrashamTrivedi
Last active September 12, 2017 21:19
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 PrashamTrivedi/ad1d888d56d17444e6ef to your computer and use it in GitHub Desktop.
Save PrashamTrivedi/ad1d888d56d17444e6ef to your computer and use it in GitHub Desktop.
Target file to properly cover recyclerview in showcase view(https://github.com/amlcurran/ShowcaseView)
/**
* Target file for ShowcaseView library, it will always points to first item of recyclerview child.
*/
public class RecyclerViewTarget implements Target {
RecyclerView recyclerView;
public RecyclerViewTarget(RecyclerView recyclerView) {
this.recyclerView = recyclerView;
}
@Override
public Point getPoint() {
int[] location = new int[2];
View childAt = recyclerView.getChildAt(0);
childAt.getLocationInWindow(location);
int x = location[0] + childAt.getWidth() / 2;
int y = location[1] + childAt.getHeight() / 2;
return new Point(x, y);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment