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
android android-recyclerview showcaseview


source to share


No one has answered this question yet

Check out similar questions:

3606
Close / hide Android soft keyboard
3295
Why is the Android emulator so slow? How can we speed up the development of an Android emulator?
3288
Correct use cases for Android UserManager.isUserAGoat ()?
2609
Is there a unique identifier for an Android device?
2510
How to persist android activity state by persisting instance state?
2097
Is there a way to run Python on Android?
1844
What is "Context" on Android?
877
Why doesn't RecyclerView have onItemClickListener ()?
868
How to add separators and spaces between items in RecyclerView?
782
How do I create a RecyclerView with multiple view types?



All Articles
Loading...
X
Show
Funny
Dev
Pics