Last active
September 12, 2017 21:19
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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
edit: https://github.com/clbemre/RecyclerViewTarget/blob/master/RecyclerViewTarget.java