Android Question Strange behaviour buttons (SOLVED)

Douwe Siegersma

Member
Licensed User
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.
Screenshot_20220408-191359.jpg
Screenshot_20220408-191359.jpg
Screenshot_20220408-191329.jpg
Screenshot_20220408-191359.jpg
Screenshot_20220408-191329.jpg
 

klaus

Expert
Licensed User
Longtime User
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

Sagenut

Expert
Licensed User
Longtime User
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

Douwe Siegersma

Member
Licensed User
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
Top