[英]Codenameone How to change Picker Text color
Picker has two components : Picker 有两个组件:
It makes sense that we can not control the theme/color/style
of Native Pickers as they are influenced by an OS-specific theme selected by the user.我们无法控制Native Pickers的
theme/color/style
是有道理的,因为它们受用户选择的操作系统特定主题的影响。
But how do we change the color of text inside the picker in Codenameone Interface?但是我们如何在 Codenameone 界面中更改选择器内文本的颜色? What I want to do in the following screenshot is to make the texts "
3/20/20, 00:00, & 0-5 persons
" white.在下面的屏幕截图中,我想要做的是将文本“3/
3/20/20, 00:00, & 0-5 persons
” 3/20/20, 00:00, & 0-5 persons
白色。
What I tried :我试过的:
timePicker.style.fgColor = 0xfffff
timePicker.style.fgColor = 0xfffff
In CSS I defined a style.在 CSS 中,我定义了一个样式。
DropdownStyle{ background-color: #333333; color: #FFFFFF; }
Then I set the style to picker然后我将样式设置为选择器
datePicker.uiid ="DropdownStyle"
But none of the above ways worked as expected.但是上述方法都没有按预期工作。
What is the right way to do it?正确的做法是什么? I believe I am missing a very simple thing but I couldn't find it myself.
我相信我错过了一件非常简单的事情,但我自己找不到。
AS @shai-almog suggested, after digging through Component Inspector , I found out that AS @shai-almog 建议,在挖掘Component Inspector 后,我发现
PickerComponent
has the ID "TextComponent"
so if we replace the UIID
of PickerComponent
it's going to change the style of just the Holder Component that's why I was able to change the background-color only but not the text . PickerComponent
的 ID 为"TextComponent"
因此如果我们替换UIID
的PickerComponent
它将仅更改Holder Component的样式,这就是为什么我只能更改 background-color 而不能更改 text 。Picker
which Represents the Text and has the id TextComponentField
.Picker
代表文本并且具有 id TextComponentField
。 So I had to Style them individually like this :所以我不得不像这样单独设计它们:
TextComponent{
background-color: rgba(0, 0, 0, 0.0);
}
TextComponentField{
color: white;
}
Output :输出 :
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.