Android Question B4XView SetBitmap

Alex_197

Well-Known Member
Licensed User
Longtime User
Hi all

I want to show a B4XView (button) with an icon and border.

My code is
B4X:
        Button1.SetColorAndBorder(Colors.green,2dip,Colors.Black,0dip)
        Button2.SetColorAndBorder(Colors.White,2dip,Colors.Black,0dip)

        Dim bmp As Bitmap
        bmp.Initialize(File.DirAssets,"rx.png")
 

 
        Button1.SetBitmap(bmp)
        
        bmp.Initialize(File.DirAssets,"hearbit32.png")
 
        Button2.SetBitmap(bmp)

The icon shown correctly but without a border around the button. Is it possible to show a border and the icon on the same button?

Thanks
 

mangojack

Expert
Licensed User
Longtime User
One option using CSBuilder ... but unable to get the image to fill the buttons, so unsure if this will suit you.
B4X:
Dim cs As CSBuilder
    cs.Initialize
    cs.Image(LoadBitmap(File.DirAssets, "rx.png"), 40dip, 40dip, False)
    Button1.SetColorAndBorder(Colors.green,2dip,Colors.Black, 0)
    Button1.Text = cs
  
    cs.Initialize
    cs.Image(LoadBitmap(File.DirAssets, "hearbit32.png"), 40dip, 40dip, False)
    Button2.SetColorAndBorder(Colors.White,2dip,Colors.Black, 0)
    Button2.Text = cs

Other than that possibly just use a panel overlay / underlay for the border
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Other than that possibly just use a panel overlay / underlay for the border
This will be the simplest solution.

Calling B4XView.SetColorAndBorder and B4XView.SetBitmap, both replace the view's drawable with a new one so they cannot be used together.
 
Upvote 0
Top