I am providing CustomView to the Android developer through Android Library project. Inside the Library project, I want to detect whether this view is getting rendered and visible to the User ( By visible I mean viewed by the User).
I thought of few approaches,
I could override onDraw
or dispatchDraw
methods to detect when view is drawn on the screen but this doesn't mean the CustomView is viewed by the user.
If View is inside the scrollview, There are ways to detect whether view is visible to the user. This is working but when I have explicit reference to scrollview on which I can add scroll event listener. The only thing I will have access, is context object and initialized reference of CustomView
Since, I am providing my project as jar dependency or jar to the developer, How could I ensure my View is visible to the User