代号一-按代码添加UIID

时间:2018-11-24 20:03:25

标签: codenameone

我想在我的代码中添加UIID

Style mystyle = new Style();
    mystyle.setBgColor(0x0x3F51B5);
    mystyle.setFgColor(0xFFFFFF);
    mystyle.setAlignment(Button.CENTER);
    mystyle.setBorder(RoundBorder.create()
            .rectangle(true)
            .color(0x0x3F51B5).opacity(255)
            .stroke(new Stroke(3, Stroke.CAP_SQUARE, Stroke.JOIN_MITER, 20))
            .strokeColor(0xff).strokeOpacity(10));
UIManager.getInstance().setComponentStyle("mystyle", myStyle);
UIManager.getInstance().setComponentSelectedStyle("mystyle", myStyle);

它起作用,但是,当我按下按钮时,它变成了没有样式的普通文本, 我用了 : UIManager.getInstance().setComponentStyle("buttonY", myStyle,"pressed");

但是它不起作用

1 个答案:

答案 0 :(得分:0)

您非常亲密,应该将press而不是pressed用作:

UIManager.getInstance().setComponentStyle("mystyle", myStyle,"press");

有关动态更改全局样式的另一种方法,请参见this