ALBRECHT Active Member Licensed User Apr 23, 2020 #1 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: Copy 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
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: Copy 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 Apr 23, 2020 #2 Try put the "btns.Background = bmp" only at even sub like: B4X: Copy Sub btns_Click Dim bmp As BitmapDrawable bmp.Initialize(LoadBitmap(File.DirAssets, "alot.jpg")) btns.Background = bmp End Sub Upvote 0
Try put the "btns.Background = bmp" only at even sub like: B4X: Copy Sub btns_Click Dim bmp As BitmapDrawable bmp.Initialize(LoadBitmap(File.DirAssets, "alot.jpg")) btns.Background = bmp End Sub
ALBRECHT Active Member Licensed User Apr 23, 2020 #3 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
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 ...
Xandoca Active Member Licensed User Longtime User Apr 23, 2020 #4 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
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...
klaus Expert Licensed User Longtime User Apr 23, 2020 #5 You should have a look at StateListDrawable! Or HERE. Upvote 0