【问题标题】:kivymd - label text color don't show the color indicatedkivymd - 标签文本颜色不显示指示的颜色
【发布时间】:2021-04-19 19:59:57
【问题描述】:

我有问题,标签文本颜色不显示指示的颜色, 它应该显示深蓝色文本颜色,但它以另一种颜色显示文本

它应该看起来像这样:

.text{
    font-size: 20px;
    color: #112651;
}
<div class="text">FULLNAME</div>

but show this text color

这是代码:

<MyInfo>:
        canvas.before:
                Color:
                        rgb: C("#f3f3f3")
                Rectangle:
                        pos: self.pos
                        size: self.size
        spacing: "10dp"

        ListItemLayoutProfile:
                size_hint:(0.3,1)
                LabelForList:
                        text: "Some text here"
                        color: (17, 38, 81, 1) #<-----this is (#112651;) in rgba------>
    ...
    ....
BoxLayout:
    size_hint: (1,0.715)
    spacing:"5dp"
    canvas:
        Color:
            rgb: C("#e9ebed")
        Rectangle:
            pos: self.pos
            size: self.size                                                             
    RecycleView:
        id: rv
        bar_width: dp(7)
        viewclass: 'MyInfo'
            RecycleBoxLayout:
            id: rbl
            default_size: None, dp(35)
            default_size_hint: 1, None
            size_hint_y: None
            height: self.minimum_height
                orientation: "vertical"
                spacing: dp(4)

但是如果我像这样更改值,文本是黑色的正确

LabelForList:
       text: "Some text here"
       color: (0,0,0,1) #<--------this ok, but I need (17, 38, 81, 1)---->

【问题讨论】:

    标签: kivy kivymd


    【解决方案1】:

    color: 期望 RGBA 值在 0-1 范围内浮动,其中 1 是最大亮度。看起来您提供了 0-255 范围内的值,大概是 8 位颜色,255 表示最大亮度。

    要将您的格式转换为 Kivy 的预期格式,请将您的数字除以 255。

    【讨论】:

      猜你喜欢
      • 2019-06-26
      • 2011-08-11
      • 2016-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多