deano2390 / MaterialShowcaseView

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

Using setDismissOnTargetTouch(true) on a sequence #189

Open ChristopheVersieux opened 4 years ago

ChristopheVersieux commented 4 years ago

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 commented 4 years ago

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();