Skip to content
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

assign target to view.. #27

Closed
fadlifebriansyah opened this issue Apr 10, 2018 · 7 comments
Closed

assign target to view.. #27

fadlifebriansyah opened this issue Apr 10, 2018 · 7 comments

Comments

@fadlifebriansyah
Copy link

fadlifebriansyah commented Apr 10, 2018

Hi,

im trying to implement the library, but i cant put target as a view to method setPoint(textview1);

the round is not fit to the view..

any advice would help much.

thanks

@fadlifebriansyah
Copy link
Author

SimpleTarget simpleTarget = new SimpleTarget.Builder(this)
//location 1 = kiri kanan, location 2 = atas bawah
.setPoint(findViewById(R.id.view1)) // position of the Target. setPoint(Point point), setPoint(View view) will work too.
.setRadius(200f) // radius of the Target
.setTitle(getResources().getString(R.string.preview_step1_title))
.setDescription(getResources().getString(R.string.preview_step1_text))
.setOnSpotlightStartedListener(new OnTargetStateChangedListener() {
@OverRide
public void onStarted(SimpleTarget target) {
// do something
}

                @Override
                public void onEnded(SimpleTarget target) {
                    // do something
                }
            })
            .build();

    Spotlight.with(PreviewActivity.this)
            .setOverlayColor(ContextCompat.getColor(PreviewActivity.this, R.color.background))
            .setDuration(1000L)
            .setAnimation(new DecelerateInterpolator(2f))
            .setTargets(simpleTarget)
            .setClosedOnTouchedOutside(true)
            .setOnSpotlightStartedListener(new OnSpotlightStartedListener() {
                @Override
                public void onStarted() {

                }
            })
            .setOnSpotlightEndedListener(new OnSpotlightEndedListener() {
                @Override
                public void onEnded() {
                    ll1.setVisibility(View.VISIBLE);
                    btnClose1.setVisibility(View.VISIBLE);
                    btnNext1.setVisibility(View.VISIBLE);
                }
            })
            .start();

@TakuSemba
Copy link
Owner

Can you give me a screenshot of how the spotlight isnt fit.

@AndresMorelos
Copy link

I had the same issue, the spotligth isn't fit

Code:

Spotlight.with(this)
                .setOverlayColor(ContextCompat.getColor(this,R.color.background))
                .setDuration(1000L)
                .setAnimation(DecelerateInterpolator(2f))
                .setTargets(
                        SimpleTarget.Builder(this)
                                .setPoint(100f,Intentos.y)
                                .setRadius(100f)
                                .setTitle("Intentos")
                                .setDescription("Este es el contador de los intentos que has realizado,recuerada el maximo es 20!!.")
                                .build()
                ,
                        SimpleTarget.Builder(this)
                                .setPoint(Chronometer.x, Chronometer.y)
                                .setRadius(100f)
                                .setTitle("Cronometro")
                                .setDescription("Tiempo que ha pasado mientras intentas adivinar la palabra.")
                                .build()
                ,
                        SimpleTarget.Builder(this)
                                .setPoint(horizontalScrollView.x , horizontalScrollView.y)
                                .setTitle("Letras")
                                .setDescription("Cada botón representa una letra o caracter, puedes buscar el que necesites pasando el dedo de izquierda a derecha o viceversa")
                                .build()
                )
                .setClosedOnTouchedOutside(true)
                .setOnSpotlightStartedListener {

                }
                .setOnSpotlightEndedListener {

                }
                .start()

Image:
whatsapp image 2018-04-27 at 9 22 51 am

@TakuSemba
Copy link
Owner

TakuSemba commented Apr 28, 2018

Can you try after view is located as I described in Read.me?

view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
    @Override public void onGlobalLayout() {
        view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        // show spotlight here
    }
});

@AndresMorelos
Copy link

Instrucciones.getViewTreeObserver().addOnGlobalLayoutListener{
            object : ViewTreeObserver.OnGlobalLayoutListener {
                override fun onGlobalLayout() {
                    Instrucciones.viewTreeObserver.removeOnGlobalLayoutListener(this)
                    Spotlight.with(this@instructions)
                            .setOverlayColor(ContextCompat.getColor(this@instructions, R.color.background))
                            .setDuration(1000L)
                            .setAnimation(DecelerateInterpolator(2f))
                            .setTargets(
                                    SimpleTarget.Builder(this@instructions)
                                            .setPoint(Intentos)
                                            .setRadius(100f)
                                            .setTitle("Intentos")
                                            .setDescription("Este es el contador de los intentos que has realizado,recuerada el maximo es 20!!.")
                                            .build()
                                    ,
                                    SimpleTarget.Builder(this@instructions)
                                            .setPoint(Chronometer)
                                            .setRadius(100f)
                                            .setTitle("Cronometro")
                                            .setDescription("Tiempo que ha pasado mientras intentas adivinar la palabra.")
                                            .build()
                                    ,
                                    SimpleTarget.Builder(this@instructions)
                                            .setPoint(horizontalScrollView)
                                            .setTitle("Letras")
                                            .setDescription("Cada botón representa una letra o caracter, puedes buscar el que necesites pasando el dedo de izquierda a derecha o viceversa")
                                            .build()
                            )
                            .setClosedOnTouchedOutside(true)
                            .setOnSpotlightStartedListener {

                            }
                            .setOnSpotlightEndedListener {

                            }
                            .start()
                }

            }

        }

with this code the spotlight doesn't start/show

@TakuSemba
Copy link
Owner

the code above, is the callback even called?
you mean the callback of the onGlobalLayout is called but spotlight doesnt start?

@TakuSemba
Copy link
Owner

sorry, closing this issue as not seeing your response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants