Open nikhilpawar151 opened 7 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.
@ahmadmssm
You can submit a pr as well if you want others to enjoy from your code. Thanks in advance!
@ahmadmssm Can you share with us please how were you able to overcome this problem?
@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);
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.