Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using setDismissOnTargetTouch(true) on a sequence #189

Open
ChristopheVersieux opened this issue Feb 22, 2020 · 1 comment
Open

Using setDismissOnTargetTouch(true) on a sequence #189

ChristopheVersieux opened this issue Feb 22, 2020 · 1 comment

Comments

@ChristopheVersieux
Copy link

As I understand, we cannor get rid of the Got it button in the sequence, I think that we should also be able to use setDismissOnTargetTouch(true).

Maybe I missed something?

@nelner
Copy link

nelner commented May 29, 2020

It is possible to not show the GOT IT text, but instead to dismiss when tapping on the target.
This is what I do to use a button as target, and waiting for a click:

MaterialShowcaseSequence sequence = new MaterialShowcaseSequence(this);
MaterialShowcaseView.Builder sequenceBuilder;

final int COLOR_MASK = getResources().getColor(R.color.colorPrimaryDarkA90);
final int COLOR_DISMISS = getResources().getColor(R.color.colorAccent);

sequenceBuilder = new MaterialShowcaseView.Builder(this)
                // Set the start button to be the target of the show
                .setTarget(findViewById(R.id.start_btn))
                //On some devices, MSV mistakenly thinks that there's a nav bar
                .renderOverNavigationBar()
                // Dismiss when we touch the START button
                .setDismissOnTargetTouch(true)
                // Set the target, touchable, otherwise, the setDismissOnTargetTouch(true) will
                // not have no effect
                .setTargetTouchable(true)
                // The description of the step
                .setContentText(getString(R.string.tutorial_start, getString(R.string.start)))
                // Delay a bit to let the user seeing the beautiful animation
                .setDelay(100)
                // Set it rectangular - best fit for our START button
                .withRectangleShape()
                // Set our primary color
                .setMaskColour(COLOR_MASK)
                // Set our accent color for dismiss text
                .setDismissTextColor(COLOR_DISMISS);
// Add the configured builder to the sequence
sequence.addSequenceItem(sequenceBuilder.build());

// Add more sequenceBuilder items to the sequence, then start it

// Start the tutorial sequence
sequence.start();

You do not have to use the builder, if you do not want to change the colors (right now, config set colors functions do not work).
In that case simply use:

 new MaterialShowcaseView.Builder(this)
                // Set the start button to be the target of the show
                .setTarget(findViewById(R.id.start_btn))
                //On some devices, MSV mistakenly thinks that there's a nav bar. 
                .renderOverNavigationBar()
                // Dismiss when we touch the START button
                .setDismissOnTargetTouch(true)
                // Set the target, touchable, otherwise, the setDismissOnTargetTouch(true) will
                // not have no effect
                .setTargetTouchable(true)
                // The description of the step
                .setContentText(getString(R.string.tutorial_start, getString(R.string.start)))
                // Delay a bit to let the user seeing the beautiful animation
                .setDelay(100)
                // Set it rectangular - best fit for our START button
                .withRectangleShape()
                // Show the tutorial overlay
                .show();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants