MaterialShowcaseView
MaterialShowcaseView copied to clipboard
Custom mask color too transparent
I want to set the color of the mask to a different color, but when I do, the mask is barely visible and the text is not legible being set against the underlying content (I'm using a dark theme for my app).
Is there a way to set the alpha transparency of the mask?
private MaterialShowcaseView getSequence(View view, int title, int desc, String dismiss, int maskColor, int maskAlpha) {
maskColor = addAlphaToColor(maskColor,` maskAlpha, getActivity());
return new MaterialShowcaseView.Builder(getActivity())
.setTarget(view)
.setTitleText(title)
.setContentText(desc)
.setDismissText(dismiss)
.setFadeDuration(150)
.setDelay(0)
.setMaskColour(maskColor)
.setContentTextColor(Color.WHITE)
.build();
}
private int addAlphaToColor(int color, int alpha) {
int red = Color.red(color);
int green = Color.green(color);
int blue = Color.blue(color);
return Color.argb(alpha, red, green, blue);
}
private int addAlphaToColor(int colorId, int alpha, Context context) {
return addAlphaToColor(ContextCompat.getColor(context, colorId), alpha);
}
@mweiczorek I used this code to add alpha to a custom color:
.setMaskColour((ContextCompat.getColor(this, R.color.accent_color) & 0x00FFFFFF) | 0xdd000000)
.setMaskColor(Color.parseColor("#AARRGGBB")); // e.g. #d9000000 transparent black
Transparency is controlled by the alpha channel (AA in #AARRGGBB). Maximal value (255 dec, FF hex) means fully opaque. Minimum value (0 dec, 00 hex) means fully transparent. Values in between are semi-transparent, i.e. the color is mixed with the background color