Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button with colored background

Tags:

go

fyne

I am using fyne. I am working on a game (with buttons obviously). I would like to know if there is a way to change button's background? I know there is button with image instead of text, but I would only like to change background color of button.

like image 806
TemplarA Avatar asked Nov 19 '25 19:11

TemplarA


1 Answers

The Fyne widget APIs are based on meaning rather than graphics, which makes two potential answers. You can mark a button as high importance (Button.Importance = widget.HighImportance) which will show as a primary colour.

If your application wishes to control colour then the way you do it is to place a background rectangle under the button, which will show through (e.g. as container.NewMax(canvas.NewRectangle(bgColor), button)).

like image 116
andy.xyz Avatar answered Nov 21 '25 08:11

andy.xyz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!