Small scroll bar, the design is quite complicated.
There are two types of scroll bars, one is the normal sliding scroll bar, one is the fast scroll bar
There have been XML definitions of android:scrollbars= "None" in the project, but when you swipe, it will still appear
Scroll bar, where the fast scroll bar is set for the reason Android:fastscrollenabled= "true", and the default android:fastscrollenabled is False
About the Fast scroll bar also has the minimum number of pages set, see Fashscroller Source code, when the number of pages scrolled within 4 pages, there is no quick scroll bar
Minimum number of pages to justify showing a fast scroll thumb
private static int min_pages = 4;
And:
Is there enough pages to require fast scroll? Recompute only if total count changes
if (mitemcount! = totalitemcount && visibleitemcount > 0) {
Mitemcount = Totalitemcount;
Mlonglist = Mitemcount/visibleitemcount >= min_pages;
}
And there's the picture that sometimes you might want to customize the scroll bar
The XML is defined as follows:
Android:scrollbarthumbvertical
Android:scrollbarthumbhorizontal
The code is set up as follows:
//Modify the Quick scroll bar picture
try {
Field f = AbsListView.class.getDeclaredField ("Mfastscroller");
f.setaccessible (true);
Object o = F.get (this);
f = F.gettype (). Getdeclaredfield ("mthumbdrawable");
f.setaccessible (true);
drawable drawable = (drawable) f.get (o);
drawable = Getresources (). getdrawable (R.drawable.icon);
F.set (o, drawable);
} catch (Exception e) {
e.printstacktrace ();
}
//Modify the vertical scroll bar picture
try {
Field f = View.class.getDeclaredField ("Mscrollcache");
f.setaccessible (true);
Object Scrollabilitycache = F.get (this);
f = F.gettype (). Getdeclaredfield ("ScrollBar");
f.setaccessible (true);
Object scrollbardrawable = F.get (Scrollabilitycache);
f = F.gettype (). Getdeclaredfield ("Mverticalthumb");
f.setaccessible (true);
drawable drawable = (drawable) f.get (scrollbardrawable);
drawable = Getresources (). getdrawable (r.drawable.rating_progress);
F.set (scrollbardrawable, drawable);
} catch (Exception e) {
e.printstacktrace ();
}
This article is from the "Mom 100 Development Team" blog, please be sure to keep this source http://mama100tech.blog.51cto.com/8943983/1708721
Android scroll bar