Android Question Losing rounded corners on ColorDrawable

swabygw

Active Member
Licensed User
Longtime User
Within "Sub Activity_Create(FirstTime As Boolean)"...

I have created the following ColorDrawable:
B4X:
    Dim enabled, pressed As ColorDrawable
    enabled.Initialize(Colors.ARGB(255,63,63,63), 100)
    pressed.Initialize(Colors.ARGB(255,100,100,100), 100)

And used it as such:
B4X:
    Dim sld_Up, sld_Down As StateListDrawable
    sld_Up.Initialize
    sld_Down.Initialize
    sld_Up.AddState(sld_Up.State_Pressed, pressed)
    sld_Up.AddState(sld_Up.State_Enabled, enabled)
    sld_Down.AddState(sld_Down.State_Pressed, pressed)
    sld_Down.AddState(sld_Down.State_Enabled, enabled)
    btn_RateUp.Initialize("btn_RateUp")
    btn_RateDown.Initialize("btn_RateDown")
    btn_RateUp.Background = sld_Up
    btn_RateDown.Background = sld_Down
    btn_RateUp.Padding = Array As Int(-1dip, -2dip, 0dip, 0dip)
    btn_RateDown.Padding = Array As Int(-1dip, -2dip, 0dip, 0dip)
    btn_RateUp.TextSize = 24
    btn_RateDown.TextSize = 24
    btn_RateUp.Text = "+"
    btn_RateDown.Text = "-"
    btn_RateUp.Gravity = Gravity.CENTER
    btn_RateDown.Gravity = Gravity.CENTER
    Activity.AddView(btn_RateUp, 5dip, 5dip, 50dip, 50dip)
    Activity.AddView(btn_RateDown, 5dip, 5dip, 50dip, 50dip)

The first time this runs (i.e., on startup), the circles ("enabled" and "pressed") are round as specified by the corner radius in the ColorDrawable parameter. If I navigate away and come back, the top left corner still has the rounded corner, but the other three corners of the ColorDrawable are not round anymore - they're square corners. Why might this be happening?
 
Top