Android: get row coordinates in RecyclerView

I want to use the storefront library to show a message in a line item RecyclerView

.

To do this, I need to pass the coordinates of the element to the library, and I do this in the adapter. The problem is that in the method the onBindViewHolder

coordinates are still 0. How do I get the coordinates correctly?

The way I do it is as follows:

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();
        }

      

Many thanks!

+3


source to share





All Articles