question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TapTarget is placed behind RecyclerView items.

See original GitHub issue

I’m trying to add a TapTarget in a RecyclerView item, but the TapTarget appears behind the item.

// Gets the first RecyclerView item
View view = UIUtils.getFirstVisibleItem(circlesView);
TapTarget tapTarget = TapTarget.forView(view, title, description);
new TapTargetSequence(activity).targets(tapTarget).start();
public class UIUtils {
  public static View getFirstVisibleItem(RecyclerView recyclerView) {
    View view = null;
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if(layoutManager instanceof LinearLayoutManager) {
      int index = ((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition();
      view = layoutManager.findViewByPosition(index);
    }
    return view;
  }
}

If I increase the target radius, the appearance is a little better, but is not working as I expected. Look at the second screenshot.

  • I have verified the issue exists on the latest version
  • I am able to reproduce it

Version used: com.getkeepsafe.taptargetview:taptargetview:1.7.0

Stack trace: No stack trace

Android version: 6.0

Screenshots: screenshot from 2017-01-31 18 39 58screenshot from 2017-01-31 18 41 28

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
xiphirxcommented, Feb 6, 2017

You want to use something like

final int[] location = new int[2];
view.getLocationOnScreen(location);
new Rect(location[0], location[1], location[0] + view.getWidth(), location[1] + view.getHeight());

instead of getX and getY since those methods are relative to the parent, not the screen.

1reaction
sandrocsimascommented, Feb 5, 2017

@xiphirx. Specifying a Rect is not working well. Look at the following screenshots. I draw a Rect in Canvas and I pass the same Rect to TapTarget. It should draw the circle where the rectangule is positioned. Any suggestion?

int centreX = (int) (view.getX() + view.getWidth() / 2);
int centreY = (int) (view.getY() + view.getHeight() / 2);
Rect bounds = new Rect(centreX - 100, centreY + 100, centreX + 100, centreY - 100);

Paint paint = new Paint();
paint.setColor(Color.rgb(255, 0, 0));
paint.setStyle(Paint.Style.FILL);
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.drawRect(bounds, paint);
view.setBackgroundDrawable(new BitmapDrawable(bitmap));

TapTarget tapTarget = TapTarget.forBounds(bounds, title, description);

screenshot from 2017-02-05 01 02 44 screenshot from 2017-02-05 01 02 22

Read more comments on GitHub >

github_iconTop Results From Across the Web

TapTargetView is placed behind popup menu - Stack Overflow
I created TapTargetView (or TapTargetSequence) in all of my activities and it displaying well, but for inner views of popup menu, it hides ......
Read more >
Using the RecyclerView | CodePath Android Cliffnotes
Every adapter has three primary methods: onCreateViewHolder to inflate the item layout and create the holder, onBindViewHolder to set the view attributes based ......
Read more >
Examples | Material Tap Target Prompt - GitHub Pages
A Tap Target implementation in Android based on Material Design Onboarding ... In the menu xml file the item will look something like...
Read more >
Pagination Android Tutorial with RecyclerView: Getting Started
Android Tutorial on how to add Pagination (Endless scrolling or ... Loading the next set of data (next page), by specifying its index...
Read more >
Customize your RecyclerView - Android Developers
Advanced customization options for RecyclerView. ... to activate an item by tapping it, or is attempting to drag and drop an item or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found