Strange button behaviour

sconlon

Active Member
Licensed User
Longtime User
I have noticed some strange behaviour with some buttons on various screens of my app. Sometimes when as new panel is displayed or made visible again a button on the screen changes shape from having rounded edges to just the top left corner being rounded and the rest as square. In one case I removed a line of code that did a panel.bringtofront and that stopped the behaviour.

In all cases I am using code as below to setup the buttons and the button drawable property is set to Defaultdrawable.

B4X:
btnClearDrawable.Initialize
btncdEnabled.Initialize(btnColorEnabled,15)
btncdEnabled1.Initialize(btnColorEnabled1,15)
btncdPressed.Initialize(btnColorPressed,15)
btndefaultdrawable.Initialize(btnColorEnabled,15)
btnClearDrawable.AddState(btnClearDrawable.State_Pressed, btncdPressed)
btnClearDrawable.AddState(btnClearDrawable.State_Enabled, btncdEnabled)
btnClearDrawable.AddCatchAllState(btndefaultdrawable)
btnclear.Background = btnClearDrawable
btnclear.TextColor = Main.btntextcolor2

Thanks for any help.
 

sconlon

Active Member
Licensed User
Longtime User
Yes, one such button in on a panel that is 100%y in height and the button is only 8%y. They all display ok initially and it is only when I make another panel visible or bring to front that this happens. If I press the button it regains it's normal shape.
 
Upvote 0

sconlon

Active Member
Licensed User
Longtime User
I have stripped the project down as much as I could and still have the problem occur. It happens twice for me when I run this project.

1. If you tap History and then press the (phone's) Back key the Contact Info button changes shape.

2. In the History screen if you tap Clear and select any of the options then tap Ok and repeat the process at some stage the OK and Cancel buttons will change shape.

I hope I have exported the project correctly as I haven't tried this before.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You must dim the ColorDrawables for each Button like below.
B4X:
Dim btncdEnabled, btncdPressed As ColorDrawable
btncdEnabled.Initialize(btnColorEnabled,15)
btncdPressed.Initialize(btnColorPressed,15)
btnCNTdrawable.AddState(btnCNTdrawable.State_Pressed, btncdPressed)
btnCNTdrawable.AddState(btnCNTdrawable.State_Enabled, btncdEnabled)
btnCNTdrawable.AddCatchAllState(btndefaultdrawable)
It's possible to add a Code Module to do this an example is added in your project.
You must do it for each Button.

Best regards.
 
Upvote 0
Top