deano2390 / MaterialShowcaseView

A Material Design themed ShowcaseView for Android
Apache License 2.0
2.72k stars 526 forks source link

set target as overflow icon (3 dot on toolbar) in materialshowcaseview #115

Open nikhilpawar151 opened 7 years ago

nikhilpawar151 commented 7 years ago

How to set target as overflow icon of menu as target for MaterialShowCaseView? I want to show user that there are some options also present and you can use it.

ahmadmssm commented 5 years ago

I know this is late but i just came into the same problem and found a solution for it, so if you mean menu items please let me know and i will provide you with the solution i applied.

noordawod commented 5 years ago

@ahmadmssm

You can submit a pr as well if you want others to enjoy from your code. Thanks in advance!

youseftcg commented 5 years ago

@ahmadmssm Can you share with us please how were you able to overcome this problem?

ahmadmssm commented 5 years ago

@yousefjoe4 Sure, Toolbar items are not buttons but you can add a button or any other component that you can create programmatically using setActionView and get it using getActionView(). Example :-

ImageButton imageButton = new ImageButton(this);
imageButton.setId(123);
imageButton.setBackgroundColor(Color.TRANSPARENT);
imageButton.setImageDrawable(getResources().getDrawable(R.drawable.myIcon));
//
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
layoutParams.weight = getResources().getDimension(R.dimen.tool_bar_button_width);
layoutParams.height = (int) getResources().getDimension(R.dimen.tool_bar_button_height);
//
imageButton.setLayoutParams(layoutParams);
toolBarItem.setActionView(imageButton);
// Show hint for tool bar item/button   
showcaseView.showHintForView(toolBarItem.getActionView());
// Remove toolBarItem image button that we have added programmatically
toolBarItem.setActionView(null);