带有彩色背景的按钮

huangapple go评论88阅读模式
英文:

Button with colored background

问题

我正在使用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.

答案1

得分: 3

Fyne小部件API基于含义而不是图形,这有两个潜在的答案。
您可以将按钮标记为高重要性(Button.Importance = widget.HighImportance),这将显示为主要颜色。

如果您的应用程序希望控制颜色,您可以在按钮下方放置一个背景矩形,它将透过显示出来(例如,container.NewMax(canvas.NewRectangle(bgColor), button))。

英文:

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)).

huangapple
  • 本文由 发表于 2021年11月25日 20:31:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/70111173.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定