I am using this github library https://github.com/amlcurran/ShowcaseView to display overlay on view elements of my app during user onboarding (or first time app open after install).
This library requires the view as input and displays overlay on your activity focusing on that view so that you could tell users more about that view.
I have a listView with fast scroll enabled. I want to display overlay on the fast scroll thumb. Hence I want to get view of my listView's fast scroll thumb, but due to absence of any public method in absListView implementation, I'm unable to do this.
Please help.
The
FastScrollerimplementation forListViewvaries by Android version. Prior to KitKat (API 19), the thumb is aDrawablethat's drawn directly on theListView. Starting with KitKat, the thumb is anImageViewthat's added to theListView'sViewGroupOverlay. In either case, it's easy enough to get what we need through reflection.Since the ultimate goal is to use this with
ShowcaseView, it makes sense to just concern ourselves with the dimensions and coordinates of the thumb, regardless of its specific type. In this way, we can useShowcaseView'sPointTarget, no matter the Android version.The following reflective method grabs a
ListView'sFastScrollerinstance, determines the thumb's size and location using the appropriate type, and returns aPointobject with the coordinates of the thumb's center point, if possible.To use this with
ShowcaseView, we simply check that the returnedPointis not null, and pass theBuilderaPointTargetcreated from the return.