gpt4 book ai didi

css - JavaFX 2.2 - 在 ListCell 中隐藏 progressIndicator 的百分比

转载 作者:技术小花猫 更新时间:2023-10-29 11:28:52 27 4
gpt4 key购买 nike

我有一个 ListCell,其中我通过 ProgressIndicator 显示文件下载的进度信息。

我的问题是删除指示器下方显示的百分比信息。如前所述here ,我在我的 css 中包含了如下规则:

.customProgressIndicator .percentage{
visibility: hidden;
-fx-text-background-color: red;
}

-fx-text-background-color: red 部分只是为了确保我们的 css 应用于节点。

问题是,我调用了 indicator.setProgress(progress),百分比变为可见(红色),当我将光标悬停在指示器上时,它再次变为不可见。同样在最后,“完成”文本在调用 indicator.setProgress(1.0) 时在底部变为可见,并在悬停后再次变为不可见。

它可能与 ListView 有关,因为;悬停并使其变得不可见后,如果我从 List 中删除一个元素并在 ListCell 上产生一个 updateItem,它会再次变得可见。

我尝试了一种解决方法:

    Text text = (Text)indicator.lookup(".percentage");
if ( text != null )
{
text.setText("");
}

但是 text有时 null,有时不是。

最佳答案

注意事项:

1) 我阅读了您链接的帖子,OP 隐含地确认了 visibility: hidden; 对他/她有用。但是我已经测试了相同的代码,但它不起作用。可能是由于版本差异。我不知道。

2) -fx-text-background-color 不是 CSS 属性。它是 caspian.css 中的预定义颜色。所以改变它你隐含地改变百分比标签的颜色,在

中定义为默认值
.progress-indicator .percentage {
-fx-font-size: 0.916667em; /* 11pt - 1 less than the default font */
-fx-fill: -fx-text-background-color;
}

的 caspian.css。 (注意上面的 -fx-text-background-color)

3)最后通过

就可以做出你想要的效果了
.customProgressIndicator .percentage {
-fx-fill: null;
}

附言我没有在 ListView 中测试进度指示器。

关于css - JavaFX 2.2 - 在 ListCell 中隐藏 progressIndicator 的百分比,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14709414/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com