Android Question ScrollView Edge properies

Erel

B4X founder
Staff member
Licensed User
Longtime User
You are asking about the scrollbar thumb, right? You can change its color:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   Dim cd As ColorDrawable
   cd.Initialize(Colors.Yellow, 10dip)
   SetThumbColor(ScrollView1, cd)
End Sub

Private Sub SetThumbColor(sv As ScrollView, drawable As Object)
   Try
     Dim r As Reflector
     r.Target = sv
     r.Target = r.GetField("mScrollCache")
     r.Target = r.GetField("scrollBar")
     r.RunMethod4("setVerticalThumbDrawable", Array(drawable), Array As String("android.graphics.drawable.Drawable"))
   Catch
     Log("SetThumbColor not supported.")   
   End Try
End Sub

Note that this code is based on private APIs so it might fail in a future Android version.
 
Upvote 0

EvgenyB4A

Active Member
Licensed User
Longtime User
Ok. The color and form is changed. But the width is not changed if you vary parameter 10dip to 120dip in cd.initilize(...)
 
Upvote 0

EvgenyB4A

Active Member
Licensed User
Longtime User
The second parameter is the corner radius. It has nothing to do with the width.

Try to use a BitmapDrawable instead of ColorDrawable. Note that thumb is only an indicator. The user cannot drag it.
OK. I will try. Thanks a lot
 
Upvote 0
Top