Closed XiXiongMaoXiong closed 4 years ago
It's probably because you haven't waited until the views are inflated.
Can you try this below?
https://github.com/TakuSemba/Spotlight/blob/master/README.md
If you want to show Spotlight immediately, you have to wait until views are laid out.
// with core-ktx method.
view.doOnPreDraw { Spotlight.Builder(this)...start() }
I'm closing this because this will be resolved by the suggestion above.
Hey, i'm experiencing the same problem... BTW, I think NotNotMarshall did as instructed here.
It's probably because you haven't waited until the views are inflated.
Can you try this below?
https://github.com/TakuSemba/Spotlight/blob/master/README.md
If you want to show Spotlight immediately, you have to wait until views are laid out.
// with core-ktx method. view.doOnPreDraw { Spotlight.Builder(this)...start() }
I am already doing this, forgot to include it in my question. But still it is in the corner... I tried both methods: onPreDraw and post{}
But no use.
I used the solution mentioned here: https://stackoverflow.com/questions/32400211/view-getx-and-gety-return-0-0-after-they-have-been-added-to-the-activity
just put the code building the target and spotlight inside this code (assuming view is the view which is the anchor of your spotlight):
view.getViewTreeObserver().addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { // Layout has happened here.
// put target and spotlight code here
// Don't forget to remove your listener when you are done with it.
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
By the way I am using Material design UI elements the button class is com.google.android.material.button.MaterialButton. Though I checked with regular Button class but it didn't work. In the corner again...