Open sandrocsimas opened 8 years ago
This was a stylistic choice to draw attention to the title by reducing the colour of the content.
Yes, but the user can set this in setContentTextColor, setting a transparent color. As you said, it should be a choice and i didn't like the way it was. =( When i set the content text color to WHITE, it was very bad to read, depending the colors you use as your background. Furthermore, i think its bad practice to change the contentText inside the setTitleText method. This is not clear to user. See my PR: #85
![Uploading Screenshot_20160319-204354.png…]()
@sandro-csimas has a very valid point. It is not intuitive to change the content style based on the title text. Doing so removes too much control from the developer. Now if I want to have full control over the text I'll have to use Spannables with line breaks, set that as the content text and avoid setting the title all together which is a very cumbersome solution to this issue.
All that being said. I'm loving this library. Thanks!
Agree that this should NOT exist in the library, but offloaded to the developer. Opacity should not change.
This can be solve via reflection like described here: https://github.com/deano2390/MaterialShowcaseView/issues/7#issue-101426494 `
MaterialShowcaseView showcaseView = builder.build();
Field field = null;
try {
field = MaterialShowcaseView.class.getDeclaredField("mContentTextView");
field.setAccessible(true);
TextView textView = (TextView)field.get(showcaseView);
textView.setAlpha(1.0f);
} catch (NoSuchFieldException e) {
} catch (IllegalAccessException e) {
}
`
Without Reflection, you can use SpannableString
to the contentText
directly.\
Example:
// Not a very good way
private fun getShowcaseContent(): SpannableString {
val title = "New Feature! \n\n"
val content = "Check out this awesome new feature, blah blah blah! 🥳"
val spannableString = SpannableString(title + content)
// 1.5f for title i.e. default text size * 1.5f
spannableString.setSpan(RelativeSizeSpan(1.5f), 0, title.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
// 0.85f for content i.e. default text size * 0.85f, smaller than the title
spannableString.setSpan(RelativeSizeSpan(0.85f), title.length + 1, (title + content).length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
return spannableString
}
Usage:
MaterialShowcaseView.Builder(this@Activity)
.setTarget(view)
// remember to set ONLY the CONTENT
.setContentText(getShowcaseContent())
// I don't need the dismiss button, so...
.setDismissText("")
.setTargetTouchable(true)
.withCircleShape()
.setDelay(250)
.setDismissOnTargetTouch(true)
.singleUse("show_case")
.show()
This should fix the alpha
as well as the Big title font issue on content if the title is used.
Why this code sets the mContextTextView alpha to 0.5?
Setting the content text color does not solve the problem...