deano2390 / MaterialShowcaseView

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

Custom mask color too transparent #118

Open nolawnchairs opened 7 years ago

nolawnchairs commented 7 years ago

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?

buutqn commented 7 years ago
 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);
    }
Dona278 commented 6 years ago

@mweiczorek I used this code to add alpha to a custom color: .setMaskColour((ContextCompat.getColor(this, R.color.accent_color) & 0x00FFFFFF) | 0xdd000000)

gvortel commented 6 years ago

.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