MaterialShowcaseView icon indicating copy to clipboard operation
MaterialShowcaseView copied to clipboard

How to underline and setBackgroundColor to DismissText?

Open hasnain-ahmad opened this issue 8 years ago • 3 comments

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.

hasnain-ahmad avatar Jul 16 '16 06:07 hasnain-ahmad

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.

da1nerd avatar Feb 09 '17 06:02 da1nerd

Doesn't work for me :S

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

Cesarsk avatar Mar 30 '17 21:03 Cesarsk

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

mahdimoqadasi avatar Jan 13 '19 11:01 mahdimoqadasi