英文:
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)
).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论