deano2390 / MaterialShowcaseView

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

How to underline and setBackgroundColor to DismissText? #99

Open hasnain-ahmad opened 8 years ago

hasnain-ahmad commented 8 years ago

I want to underline and set a background color to dismiss text. How can i achieve this? I tried to underline the text following is the code.

 new MaterialShowcaseView.Builder(ProfileActivity.this)
                        .setTarget(rlHeaderMediaVault)
                        .setDismissOnTargetTouch(true)
                        .setContentTextColor(R.color.darkBlue)
                        .setDismissText("<u>GOT IT</u>")
                        .setContentText("Click on Media Vault to start Locking Media files")
                        .setDelay(500)
                        .singleUse("two time")
                        .show();
            }

But it shows underline as it is. As you can see setDismissOnTargetTouch is true. But when i click the target view it does not dismiss the showcase.

da1nerd commented 7 years ago

The underline can be done with a spannable. Here's a helper method I use to underline the dismiss text.

public CharSequence underlineText(CharSequence text) {
        SpannableString content = new SpannableString(text);
        content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
        return content;
}

Just give it your text like NEXT and it will return a Charsequence that can be given to setDismissText.

It would be nice to set the background color of the button instead, but unfortunately the current api does not grant us access to do so. So for now I'll just live with the underline.

Cesarsk commented 7 years ago

Doesn't work for me :S

sequence.addSequenceItem(multibutton, "Text.", Utility.underlineText("DISMISS").toString());

mahdimoqadasi commented 5 years ago
private static void setBackToTextView(MaterialShowcaseView input) {
    try {
        Field field = input.getClass().getDeclaredField("mDismissButton");
        field.setAccessible(true);
        ((TextView) field.get(input)).setBackgroundResource(R.drawable.holo);
        ((TextView) field.get(input)).setPadding(30, 13, 18, 13);
    } catch (Exception e) {
        e.printStackTrace();
    }
}