ToggleButton problem

boten

Active Member
Licensed User
Longtime User
I want to have some ToggleButtons in my activity. They have to be small, but it seems that the "led lamp" in the middle of the button is not relative to the width of the button.

Any ideas how to fix this?

(see sample code & image below)

B4X:
Sub Activity_Create(FirstTime As Boolean)
Dim i,y As Int
y=0
For i=100 To 10 Step -10
  Dim tb As ToggleButton
  tb.Initialize("")
  activity.AddView(tb,100dip,y,i*1dip,i*1dip)
  tb.TextOff=i
  tb.TextOn=i
  tb.TextSize=8
  y=y+tb.Height
Next  
End Sub
 

Attachments

  • togs.jpg
    togs.jpg
    4.1 KB · Views: 269

klaus

Expert
Licensed User
Longtime User
I think you cannot change the led size of the default ToggleButton.
But you can use workarounds in changing the buttons drawable.
In the attached test program you find four different possibilities.
- with 2 different BitmapDrawables
- with a GradientDrawable
- with a ColorDrawable

Best regards.
 

Attachments

  • TestToggleButton.zip
    9.7 KB · Views: 358
  • TestToggleButtons.jpg
    TestToggleButtons.jpg
    16.9 KB · Views: 359
Upvote 0
Top