Douwe Siegersma Member Licensed User Longtime User Apr 8, 2022 #1 Hello, In the app I'm working on I use the .BackGround property a lot. For my buttons I have declared ButtonColor as ColorDrawable. But sometimes, when clicking around in the app, the appearence of some buttons change. Below is an example of a button not showing up correctly. The left is how the "Verwijderen" button should look. On the right how it shouldn't.
Hello, In the app I'm working on I use the .BackGround property a lot. For my buttons I have declared ButtonColor as ColorDrawable. But sometimes, when clicking around in the app, the appearence of some buttons change. Below is an example of a button not showing up correctly. The left is how the "Verwijderen" button should look. On the right how it shouldn't.
klaus Expert Licensed User Longtime User Apr 8, 2022 #2 Sorry, but how do you expect us to help you without any concrete information.? How do you define the Backgrounds ? How do you set the background to the views. Without seeing what exactly you have done, it is almost impossible to give a concrete advice. The only point I can guess is that you declare the backgrounds once and set it to several views. You need to initialize one background for each view. The most efficient way to get concrete help would be if you posted a small project showing the problem. Allowing us to see what exactly you have done and how and we could test it and suggest a solution. Upvote 0
Sorry, but how do you expect us to help you without any concrete information.? How do you define the Backgrounds ? How do you set the background to the views. Without seeing what exactly you have done, it is almost impossible to give a concrete advice. The only point I can guess is that you declare the backgrounds once and set it to several views. You need to initialize one background for each view. The most efficient way to get concrete help would be if you posted a small project showing the problem. Allowing us to see what exactly you have done and how and we could test it and suggest a solution.
Sagenut Expert Licensed User Longtime User Apr 8, 2022 #3 To set ColorDrawable correctly to any views create a Sub like this B4X: Sub SetCD (backcolor As Int, radius As Int, borderwidth As Int, bordercolor As Int) As ColorDrawable Dim cd As ColorDrawable cd.Initialize2(backcolor, radius, borderwidth, bordercolor) Return cd End Sub and to set it to a View call this (example) B4X: ViewName.Background = SetCD(xui.Color_Blue, 8dip, 3dip, xui.Color_White) If not using XUI just use (example) B4X: Colors.Blue Upvote 0
To set ColorDrawable correctly to any views create a Sub like this B4X: Sub SetCD (backcolor As Int, radius As Int, borderwidth As Int, bordercolor As Int) As ColorDrawable Dim cd As ColorDrawable cd.Initialize2(backcolor, radius, borderwidth, bordercolor) Return cd End Sub and to set it to a View call this (example) B4X: ViewName.Background = SetCD(xui.Color_Blue, 8dip, 3dip, xui.Color_White) If not using XUI just use (example) B4X: Colors.Blue
Douwe Siegersma Member Licensed User Longtime User Apr 8, 2022 #4 OK , sorry for the fuzzy question. If I understand it correctly I have to declare a background for each view. Even if I want all the buttons to look the same I have to declare a background for each of them. I will try it tomorrow. And I will do it the way SageNut suggested. Next time I'll try to give more details and be more clear. Please bear with me.. Upvote 0
OK , sorry for the fuzzy question. If I understand it correctly I have to declare a background for each view. Even if I want all the buttons to look the same I have to declare a background for each of them. I will try it tomorrow. And I will do it the way SageNut suggested. Next time I'll try to give more details and be more clear. Please bear with me..
Douwe Siegersma Member Licensed User Longtime User Apr 9, 2022 #5 I changed the code the way you suggested and everything is working fine now. Thank you for the assistance. Upvote 0
I changed the code the way you suggested and everything is working fine now. Thank you for the assistance.