Skip to content

Change indicator color? #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
broakenmedia opened this issue Nov 10, 2016 · 6 comments
Closed

Change indicator color? #44

broakenmedia opened this issue Nov 10, 2016 · 6 comments
Labels

Comments

@broakenmedia
Copy link

I simply want to change the non-selected and selected colors but i seems i need to set some sort of renderer before it will draw them? If i don't specify one the indicator is now invisible, can i not use the "default" renderer?

@Iojjj
Copy link
Contributor

Iojjj commented Nov 10, 2016

return newTutorialOptionsBuilder(getContext())
    .setIndicatorOptions(IndicatorOptions.newBuilder(getContext())
        .setElementColor(...)           // non-selected color
        .setSelectedElementColor(...)   // selected color
        .build())
    .build();

If you not specified Renderer then default circle renderer will be used. You always need to specify elementColor and selectedElementColor. See readme.

@Iojjj Iojjj closed this as completed Nov 10, 2016
@broakenmedia
Copy link
Author

OK, so that's exactly what i did, except as soon as i do that, the indicator is no longer rendered. See original question. Removing the setIndicatorOptions then brings back the indicator.

@Iojjj
Copy link
Contributor

Iojjj commented Nov 10, 2016

Have you tried to specify one of the default renderers?

Renderer.Factory.newCircleRenderer()
Renderer.Factory.newSquareRenderer()

@Iojjj Iojjj reopened this Nov 10, 2016
@broakenmedia
Copy link
Author

No dice i'm afraid! Still nothing at all.

@Iojjj
Copy link
Contributor

Iojjj commented Nov 11, 2016

There was an issue with DrawableRenderer that is mentioned here #36. But I doubt this will help with default circle renderer.

Provide your code of XML layout for tutorial fragment and Java code with provideTutorialOptions method.

For now try to implement your own Renderer and draw using custom Paint object. This is just a quickfix.

final Paint mElementPaint = ...; // init paint with non-selected color
final Paint mSelectedElementPaint = ...; // init paint with non-selected color

return newTutorialOptionsBuilder(getContext())
    .setIndicatorOptions(IndicatorOptions.newBuilder(getContext())
        .setRenderer(new Renderer() {

                @Override
                public void draw(@NonNull Canvas canvas, @NonNull RectF elementBounds, @NonNull Paint paint, boolean isActive) {
                    float radius = Math.min(elementBounds.width(), elementBounds.height());
                    radius /= 2f;
                    canvas.drawCircle(elementBounds.centerX(), elementBounds.centerY(), radius, isActive ? mSelectedElementPaint : mElementPaint);
                }

        })
        .build())
    .build();

@Iojjj
Copy link
Contributor

Iojjj commented Nov 11, 2016

You need to specify the size of elements as well as colors.

@Override
protected TutorialOptions provideTutorialOptions() {
    return newTutorialOptionsBuilder(getContext())
            .setIndicatorOptions(IndicatorOptions.newBuilder(getContext())
                    // set this sizes
                    .setElementSizeRes(R.dimen.indicator_size)
                    .setElementSpacingRes(R.dimen.indicator_spacing)
                    .setElementColor(Color.CYAN)
                    .setSelectedElementColor(Color.RED)
                    .build())
            .build();
}

Currently the default value for elements and spacing size is zero. That's why it doesn't draw anything.

@Iojjj Iojjj added the bug label Nov 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants