Bug? Radiobutton color or drawable not working

COBRASoft

Active Member
Licensed User
Longtime User
Hey all,

I can't change the (back)color of my radiobuttons. Trying drawable is also not working. Trying a canvas crashes the app.

I've tried in designer, connected to my device (SE Xperia Arc S) and got no results. Tried it with code, also no result.

The color remains transparent... Any1 an idea?

Greetings,
Sigurd
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Seems to be working here. I changed the color with the designer and it works. Make sure that you also change the transparent value:


You should also be able to use a canvas with RadioButton. Make sure that the RadioButton is first initialized (if created programmatically) and added to the activity before initializing the canvas.
 

COBRASoft

Active Member
Licensed User
Longtime User
Hey Erel,

I can't get it to work. See my code below please. It should add a semi-transparent red background to the radiobuttons. You can see the result on my SE Xperia Arc S on the screenshot I took.

B4X:
Dim rdbDepartmentList As RadioButton: rdbDepartmentList.Initialize("rdbDepartmentList")
rdbDepartmentList.Text = objMap.Get("CONT_CODE"): rdbDepartmentList.Tag = objMap.Get("CONT_ID")
rdbDepartmentList.TextSize = 16
Dim objColor As ColorDrawable: objColor.Initialize(Colors.ARGB(150, 255, 0, 0), 10)
rdbDepartmentList.Background = objColor
vscDepartment.Panel.AddView(rdbDepartmentList, Design.Padding, intPosY, vscDepartment.Panel.Width, Design.LabelHeight)
Greetings,
Sigurd
 

Attachments

  • Screenshot.jpg
    8.4 KB · Views: 292

Erel

B4X founder
Staff member
Licensed User
Longtime User
Try this code:
B4X:
Dim b As Button
b.Initialize("")
Activity.AddView(b, 0, 0, 100dip, 100dip)
Dim rdbDepartmentList As RadioButton
rdbDepartmentList.Initialize("rdbDepartmentList")
rdbDepartmentList.Text = "sdf"
rdbDepartmentList.TextSize = 16
Dim objColor As ColorDrawable
objColor.Initialize(Colors.ARGB(150, 255, 0, 0), 10)
rdbDepartmentList.Background = objColor
Activity.AddView(rdbDepartmentList, 0, 0, 200dip, 200dip)

This is what I get:
 

COBRASoft

Active Member
Licensed User
Longtime User
Hey Erel,

This is weird. I get the attached image (with project attached).

What could this be?

Greetings,
Sigurd
 

Attachments

  • test.jpg
    2.9 KB · Views: 295

COBRASoft

Active Member
Licensed User
Longtime User
That is possible of coarse. Can somebody else please try this project on their device?
 

COBRASoft

Active Member
Licensed User
Longtime User
I've added a panel behind the radiobutton. This works fine, but I need to create an extra view per radiobutton this way. This results in a performance penalty. My Xperia is quite fast (1.4GHz) so here it is not noticable. I'll have to test this further. Thanks for the tip and help.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…