Button + Codenameone的主题更改

时间:2018-08-20 22:29:56

标签: codenameone

图像是否有任何更改。圆形按钮显示与投影不同。使用按钮之前显示正确的圆圈。请参阅屏幕截图以供参考。请指教。

Button b;
Button finished = new Button("");
FontImage.setMaterialIcon(finished, FontImage.MATERIAL_CHECK, 8.0f);
Test.makeBorderRound(finished);
Style bg = finished.getDisabledStyle();
finished.setDisabledStyle(bg);
b = finished;
b.setDisabledStyle(bg);  

 public static void makeBorderRound(Component cmp) {
   makeBorderRound(cmp.getUnselectedStyle());
   makeBorderRound(cmp.getSelectedStyle());
   makeBorderRound(cmp.getPressedStyle());
   makeBorderRound(cmp.getDisabledStyle());
   }

public static void makeBorderRound(Style stl) {
    stl.setBorder(RoundBorder.create().
    rectangle(true).
    color(stl.getBgColor()).
    opacity(stl.getBgTransparency() & 0xff));
    stl.setPaddingUnit(Style.UNIT_TYPE_DIPS);
    stl.setPaddingLeft(1);
    stl.setPaddingRight(1);
}

enter image description here

1 个答案:

答案 0 :(得分:0)

该图标从圆形边框的边缘逐渐突出。我们修复了某些情况下背景没有绘制的错误。

一个简单的解决方法是:

Button finished = new Button("");
finished.getAllStyles().setBgTransparency(0);
FontImage.setMaterialIcon(finished, FontImage.MATERIAL_CHECK, 8.0f);
finished.getAllStyles().setBgTransparency(255);
Test.makeBorderRound(finished);

通过将bg透明度设置为0,图标将具有透明度,然后在创建图标后第二行将其覆盖。

相关问题