jaraiza Active Member Licensed User Longtime User Sep 29, 2025 #1 Hi, I've been trying adding a border to a BitmapDrawable button with the known code Code: Copy Dim cd As ColorDrawable cd.Initialize2(Colors.White, 5dip, 2dip, Colors.Black) MyButton.Background = cd But setting the button to ColorDrawable makes the image to disappear, being replaced with the specified background color/transparency. Is there any way to add the border without losing the image? (The images have been set as BitmapDrawable in the designer) Thanks!
Hi, I've been trying adding a border to a BitmapDrawable button with the known code Code: Copy Dim cd As ColorDrawable cd.Initialize2(Colors.White, 5dip, 2dip, Colors.Black) MyButton.Background = cd But setting the button to ColorDrawable makes the image to disappear, being replaced with the specified background color/transparency. Is there any way to add the border without losing the image? (The images have been set as BitmapDrawable in the designer) Thanks!
P PaulMeuris Well-Known Member Licensed User Sep 29, 2025 #2 You can put the button on a panel and set the color of that panel to a color you like to have as the bordercolor. Make the button in the designer a few dips smaller on each side. This setting will display as the left image. The right image uses an image with a transparant background and the color of the panel comes through it. B4X: Copy ' Button1.SetBackgroundImage(LoadBitmap(File.DirAssets,"angelfish.jpg")) Button1.SetBackgroundImage(LoadBitmap(File.DirAssets,"angelfish_transparant.png")) Upvote 0
You can put the button on a panel and set the color of that panel to a color you like to have as the bordercolor. Make the button in the designer a few dips smaller on each side. This setting will display as the left image. The right image uses an image with a transparant background and the color of the panel comes through it. B4X: Copy ' Button1.SetBackgroundImage(LoadBitmap(File.DirAssets,"angelfish.jpg")) Button1.SetBackgroundImage(LoadBitmap(File.DirAssets,"angelfish_transparant.png"))