如何在javafx中将边框颜色设置为头像对象?有多少种方法可以做到这一点?
这不仅仅是css模式,也是代码。我想设置边框颜色的对象是:
http://docs.gluonhq.com/charm/javadoc/3.0.0/com/gluonhq/charm/glisten/control/Avatar.html
提前致谢
答案 0 :(得分:2)
Gluon Mobile library中的自定义控件Avatar
具有用于设置图像和半径的API。
目前它没有提供用于设置边框颜色的API,但可以根据控件的设计方式来完成。
如果您使用ScenicView进行核对,则该控件的顶部为ImageView
和Circle
,并且样式为decoration
。
因此,通过代码,您可以设置此圆圈的颜色:
avatar.getChildrenUnmodifiable().get(1).setStyle("-fx-stroke: red");
或更好:
avatar.lookup(".decoration").setStyle("-fx-stroke: red");
使用CSS更容易:
.avatar > .decoration {
-fx-stroke: red;
}