在 .kv 文件中为按钮指定背景颜色属性,并且两个 rgba 字段中的值超过 220.0/255 时,它会返回到默认的灰色。 我使用 FloatLayout 的代码摘录
Button:
size_hint : 0.95/18, 0.1
pos_hint : {"center_x" : 0.95, "center_y" : 0.925}
font : 40
background_color: 1.0, 225.0/255, 228.0/255, 0
color: 211.0/255, 54.0/255, 112.0/255, 1
text: "Sample Text"
halign : "center"
我尝试减少 RGB 字段的值及其工作,但它没有给出高于 220.0/255 值的颜色。我尝试将其转换为最多两位小数浮点数,但它仍然返回相同的值。
约翰·安德森的评论对我有用,
self.my_button.background_normal=''
self.my_button.background_color=[1,1,1,1]
完美地将按钮的背景更改为白色。