Android Question Color priority

ALBRECHT

Active Member
Licensed User
Hello,

I have a button that is initialize as bellow, and which have 2 properties : a Background Color and a Background image

and i would to see the Background image only when i Click the button and set the Color property to Transparent,

B4X:
        Dim btns As Button
        Dim bmp As BitmapDrawable
        Dim Images As String
        Dim coul As Int
        
        Images = "SomeImage.png"
        bmp.Initialize(LoadBitmap(File.DirAssets, Images)
        btns.Background = bmp
        
        coul = Colors.Magenta
        btns.Color = coul

but in that case the Background image Property disapears !

Should i have to set one more time the btns.Background value after set the Btns.Color property to Colors.Transparent ?

or make i something wrong ?

Regards
Take care ?
Michel
 

Xandoca

Active Member
Licensed User
Longtime User
Try put the "btns.Background = bmp" only at even sub like:
B4X:
Sub btns_Click
    Dim bmp As BitmapDrawable
    bmp.Initialize(LoadBitmap(File.DirAssets, "alot.jpg"))
    btns.Background = bmp
End Sub
 
Upvote 0

ALBRECHT

Active Member
Licensed User
thats what i thought for, but i was looking for to avoid the repeat to loading images each click : thats why i wanted to set the background image initialy, but if there is no other way ...
 
Upvote 0

Xandoca

Active Member
Licensed User
Longtime User
I don't know the why (your goal in not loading again) but I think you could do that by checking if there's a background set and then not load again, or two buttons in the same position and when you click one gets visible and the other not and vice versa...
 
Upvote 0

ALBRECHT

Active Member
Licensed User
ok and thank you all
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…