0

I'm using this great library. It helps me a lot. But, I got in trouble with MenuItem if the showAsAction set to ifRoom|collapseActionView. The rounded hole won't appear. Only the overlay background and text appeared. PS: I want to do showcaseview on searchView. I have search button on the top right corner, besides it there is a menu item that has showAsAction set to never. If the searchView is clicked, then the menu item changes to filter menu item.

 mSequence.addSequenceItem(new MaterialShowcaseView.Builder(getActivity())
      .setTarget(searchView)
      .setContentText(R.string.help_deals)
      .setDismissOnTouch(true)
      .build());'

Is there any solution to this problem?

batman
  • 1,937
  • 2
  • 22
  • 41
Andri Wu
  • 105
  • 1
  • 2
  • 11

1 Answers1

1

You should put the library in inside(like a module with the package name: uk.co.deanwild.materialshowcaseview) the Application Project. In order to specify a module dependency, simply:

  1. Right click on Application->Open Module Settings
  2. Click on the '+' icon
  3. Select the root directory for your library module you'd like to add.
  4. Follow the prompts

Then, this module will show up in your project. Then, you need to add it to Application as a library dependency. Once again, in your Module Settings:

  1. Select your Application module
  2. Select the Dependencies tab on the right
  3. Click the '+' icon on the bottom
  4. Select Module Dependency
  5. Select your desired library module

then, go to MaterialShowcaseView$Builder.java and add this:

public Builder setTarget(Target target) {
        showcaseView.setTarget(target);
        return this;
}

finally... in the MainActivity or your fragment create a Target class

Target mTarget = new Target() {
        @Override
        public Rect getBounds() {
            Point p = getPoint();
            return new Rect(p.x - 190, p.y - 190, p.x + 190, p.y + 190);
        }

        @Override
        public Point getPoint() {
            // Get approximate position of actions items
            int height = toolbar.getHeight();
            int width = toolbar.getWidth();
            int x = height / 2;
            int y = height / 2;
            width -= x;
            return new Point(width, y);
        }
    };new MaterialShowcaseView.Builder(getActivity())
            .setTarget(mTarget)
            .setDismissText("GOT IT")
            .setContentText("Text content")
            .setDelay(275) // optional but starting animations immediately in onCreate can make them choppy
            .singleUse("ID_OF_SHOWCASE")// provide a unique ID used to ensure it is only shown once
            .show(); 
HerberthObregon
  • 1,811
  • 19
  • 23
  • Hello @Herberth Obregon Thanks for your answer. I have not tested it. How about in nested scrollview? When i have item that it is below some items and want to automatically scroll to the highlight item. How proper way to do that? Thanks – Andri Wu Dec 24 '16 at 07:23