Using TapTargetView on Navigation Drawer menu item

415 Views Asked by At

I'm using TapTargetView to create my Showcase and it's working nice to buttons and the toolbar, but I need to target my Navigation Drawer menu and I'm not getting there.

One of my aproaches was to create a local variable TextView (or anything else) and use app:actionViewClass on my menu item. The target is reached but not like expected, because the actionViewClass is on the right margin of the menu item look the screenshot

<item
    android:id="@+id/nav_criar_projeto"
    android:icon="@drawable/ic_add"
    android:title="@string/criar_projeto"
    app:showAsAction="always"
    app:actionViewClass="android.widget.TextView" />
TapTarget.forView(
  navigationView.getMenu().findItem(R.id.nav_criar_projeto).getActionView(),
     "Vamos criar nosso primeiro projeto",
     "Você ainda não possui um projeto, vamos criar um")

Is it possible to target the icon or the text of this menu item?

1

There are 1 best solutions below

0
Renan Ceratto On BEST ANSWER

Solved this by setting app:contentDescription="name_here" to my <item> inside the <menu> Then just call

navigationView.findViewsWithText(menuItems, "name_here", View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);

But to work properly, the code above need to be called on a new thread, so the interface have enough time to render.

new Handler().post(new Runnable() {
                    @Override
                    public void run() {
                        methodToFindTheView();
                    }
                });