如何在javafx中将边框颜色设置为“头像”

时间:2017-01-18 09:24:10

标签: java javafx avatar gluon

如何在javafx中将边框颜色设置为头像对象?有多少种方法可以做到这一点?

这不仅仅是css模式,也是代码。我想设置边框颜色的对象是:

http://docs.gluonhq.com/charm/javadoc/3.0.0/com/gluonhq/charm/glisten/control/Avatar.html

提前致谢

1 个答案:

答案 0 :(得分:2)

Gluon Mobile library中的自定义控件Avatar具有用于设置图像和半径的API。

目前它没有提供用于设置边框颜色的API,但可以根据控件的设计方式来完成。

如果您使用ScenicView进行核对,则该控件的顶部为ImageViewCircle,并且样式为decoration

因此,通过代码,您可以设置此圆圈的颜色:

avatar.getChildrenUnmodifiable().get(1).setStyle("-fx-stroke: red");

或更好:

avatar.lookup(".decoration").setStyle("-fx-stroke: red");

使用CSS更容易:

.avatar > .decoration {
    -fx-stroke: red;
}