有没有办法在recyclerview上获取第三项的centerX和centerY
我用过
public static Point getViewCenterCoordinatesOnScreen(View myView) {
int[] location = new int[2];
myView.getLocationInWindow(location);
return new Point(location[0]/2, location[1]/2);
}
并且它无法正常工作。
答案 0 :(得分:0)
返回的位置是您要求的视图的0,0,它的中心不是位置除以2,正确:
public static Point getViewCenterCoordinatesOnScreen(View myView) {
int[] location = new int[2];
myView.getLocationInWindow(location);
return new Point(location[0] + (myView.getWidth() / 2), location[1] + (myView.getHeight() / 2));
}