如何获取TapTargetView的BottomNavigation项目视图参考

时间:2017-06-18 02:38:51

标签: android bottomnavigationview

我有一个底部导航视图,我正在使用TapTargetView库来指导用户如何使用某些功能。如果我通过底部导航视图,那么TapTargetView将突出显示我不想要的整个底部栏。

我的问题是如何突出底部导航视图中的特定项目?

TapTargetView.showFor(this, TapTarget.forView(findViewById(R.id.home), "Home page", "We have cool features for you"),
new TapTargetView.Listener() {
    @Override
    public void onTargetClick(TapTargetView view) {
        super.onTargetClick(view);
        itemClicked();
    }
});

感谢。

2 个答案:

答案 0 :(得分:2)

我找到了解决方案,就是这样:

BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation);
TapTargetView.showFor(this, TapTarget.forView(bottomNavigationView.findViewById(R.id.home), "Home page", "We have cool features for you"),
        new TapTargetView.Listener() {
            @Override
            public void onTargetClick(TapTargetView view) {
                super.onTargetClick(view);
                itemClicked();
            }
        });

答案 1 :(得分:0)

我还没有尝试过这个,但我认为这应该可行

TapTargetView.showFor(this, TapTarget.forView(YOURBOTTOMNAVIGATIONVIEW.getChildAt(YOUR VIEW POSITION), "Home 
page", "We have cool features for you"),
new TapTargetView.Listener() {
@Override
public void onTargetClick(TapTargetView view) {
    super.onTargetClick(view);
    itemClicked();
}
});