3

I want to use a Showcase library in order to show a message in an item of a row of a RecyclerView.

In order to do this, I need to pass to the library the coordinates of the item, and I do this in the adapter. The problem is that in the onBindViewHolder method, the coordinates are still 0. How could I properly get the coordinates?

The way I'm doing it is the following:

if (position == 2) {
            final int x = (int) ((RecyclerViewPlaceViewHolder) holder).mPlaceDescriptionTextView
                    .getX();
            final int y = (int) ((RecyclerViewPlaceViewHolder) holder).mPlaceDescriptionTextView
                    .getY();
            new ShowcaseView.Builder((Activity) mContext)
                    .setTarget(new Target() {
                        @Override
                        public Point getPoint() {
                            return new Point(x, y);
                        }
                    })
                    .setContentTitle("ShowcaseView")
                    .setContentText("This is highlighting the Home button")
                    .hideOnTouchOutside()
                    .build();
        }

Thanks a lot in advance!

noloman
  • 11,411
  • 20
  • 82
  • 129
  • Did you find a reliable solution? – seb Feb 03 '16 at 01:45
  • try this: int[] originalPos = new int[2]; holder.ivAnimateView.getLocationOnScreen(originalPos); Log.d("viewPosition","x=" + originalPos[0] + "y=" + originalPos[1]); – Bahadir Gul Nov 15 '17 at 13:09

0 Answers0