Android Code Snippet Scrollbar Color

Erel

Administrator
Staff member
Licensed User
This code uses reflection to change the ScrollView scroll bar color:



B4X:
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("android.graphics.drawable.Drawable"))
End Sub
Note that it is based on private API so it can be broken in a future version of Android.
 
Top