Android Code Snippet Scrollbar Color

This code uses reflection to change the ScrollView scroll bar color:


Sub SetScrollbarColor(sv As ScrollView, clr As Int)
   Dim r As Reflector
   r.Target = sv
   r.Target = r.GetField("mScrollCache")
   r.Target = r.GetField("scrollBar")
   Dim cd As ColorDrawable
   cd.Initialize(clr, 5dip)
   r.RunMethod4("setVerticalThumbDrawable", Array(cd), Array As String(""))
End Sub
Note that it is based on private API so it can be broken in a future version of Android.