Question

Is it possible to change the current size of circle in ShowCaseView?

What I have in my code is the following:

ShowcaseView.ConfigOptions co = new ShowcaseView.ConfigOptions();
            co.hideOnClickOutside = false;
            return ShowcaseView.insertShowcaseView(id, activity, title, message, co);

but right now, I'm just showing the default size of ShowCaseView, How can I resize it if so?

thanks!

for more info regarding ShowCaseView, this will be of help.. https://github.com/amlcurran/Showcaseview

Was it helpful?

Solution

Use setScaleMultiplier(float scaleMultiplier)

Hope help you!

OTHER TIPS

I found how to do it, we have to do some changes in the code. I'm writing this answer while current ShowcaseView release is 5.0

A) scalemultiplier became orphelin, we have to reimplement it.

1) open StandarShowcaseDrawer.java, locate drawShowcase method and modify it as bellow :

@Override
    public void drawShowcase(Bitmap buffer, float x, float y, float scaleMultiplier) {
        Canvas bufferCanvas = new Canvas(buffer);
        //[GIOVA]
        //To avoid an infinite exception
        if(scaleMultiplier == 0.0f)
            scaleMultiplier = 0.001f;
        //[/GIOVA]
        //[Original]
            //bufferCanvas.drawCircle(x, y, showcaseRadius, eraserPaint);
        //[/Original]
        //[GIOVA]
            bufferCanvas.drawCircle(x, y, showcaseRadius * scaleMultiplier, eraserPaint);
        //[/GIOVA]
        int halfW = getShowcaseWidth() / 2;
        int halfH = getShowcaseHeight() / 2;
        int left = (int) (x - halfW);
        int top = (int) (y - halfH);
        showcaseDrawable.setBounds(left, top,
                left + getShowcaseWidth(),
                top + getShowcaseHeight());
        showcaseDrawable.draw(bufferCanvas);
    }

NB : note that i've placed some [GIOVA] and [Original] tags, so you can compare changes ;)

2) open NewShowcaseDrawer.java, same job as previous step :

@Override
    public void drawShowcase(Bitmap buffer, float x, float y, float scaleMultiplier) {
        Canvas bufferCanvas = new Canvas(buffer);
        //[GIOVA]
        //To avoid an infinite exception
        if(scaleMultiplier == 0.0f)
            scaleMultiplier = 0.001f;
        //[/GIOVA]
        eraserPaint.setAlpha(ALPHA_60_PERCENT);
        //[Original]
        //bufferCanvas.drawCircle(x, y, outerRadius , eraserPaint);
        //eraserPaint.setAlpha(0);
        //bufferCanvas.drawCircle(x, y, innerRadius , eraserPaint);
        //[/Original]

        //[GIOVA]
        bufferCanvas.drawCircle(x, y, outerRadius * scaleMultiplier, eraserPaint);
        eraserPaint.setAlpha(0);
        bufferCanvas.drawCircle(x, y, innerRadius * scaleMultiplier, eraserPaint);
        //[/GIOVA]
    }

B) Now we need to be able to set the value, we'll add a method to the builder. Open ShowcaseView.java then locate following line :

public static class Builder {

Inside this Builder class, add the following method :

 public Builder setScaleMultiplier(float multiplier){
            showcaseView.setScaleMultiplier(multiplier);
            return this;
        }

How to use it :

Pretty simple now, in your activity, when you use Builder to setup your showcaseview, simply call setScaleMultiplier.

Example :

sv = new ShowcaseView.Builder(this, true)
                .setTarget(target)
                .setContentTitle(getResources().getString(R.string.welcome))
                .setContentText(getResources().getString(R.string.welcomDescription))
                .setStyle(R.style.MyTheme)
                .setScaleMultiplier(0.3f)
                .build();
sv.Show();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top