deano2390 / MaterialShowcaseView

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

Customizable text formatting #7

Open MFlisar opened 9 years ago

MFlisar commented 9 years ago

Sometimes it's nice to use spannables, html or even a custom view as content in a Showcase.

Html is quite easy and android as well allows very basic html tags in xml resources, like <b> for example. But therefore an TextViews text must be set with context.getText(res) instead of context.getString(res)... And following example shows how to use html (by reflection though, as that's what I currently use for it):

resource

<string name="tut"><![CDATA[<b>Bold text</b>... normal text]]></string>

code

MaterialShowcaseView showcaseView = builder.build();

    Field field = null;
    try {
        field = MaterialShowcaseView.class.getDeclaredField("mContentTextView");
        field.setAccessible(true);
        TextView textView = (TextView)field.get(showcaseView);
        textView.setText(Html.fromHtml(activity.getString(content)));
    } catch (NoSuchFieldException e) {
        L.e(TutorialManager.class, e);
    } catch (IllegalAccessException e) {
        L.e(TutorialManager.class, e);
    }

Just wanted to tell you this idea, for myself, I'm content with my workaround

deano2390 commented 9 years ago

Yes I had plans to allow a custom view. The spannable comment is important, i'll add it to my TODO list.