How to make a round Progress Bar in codename one?

霸气de小男生 提交于 2019-12-04 12:44:24

I haven't tested it but something like this should work:

Container progress = new Container(new LayeredLayout());
Label percent = new Label("0%");
percent.getUnselectedStyle().setAlignment(Component.CENTER);
progress.add(new Label(progressOverlayImage, "Container")).
        add(FlowLayout.encloseCenterMiddle(percent));
progress.getUnselectedStyle().setBgPainter((Graphics g, Rectangle rect) -> {
    g.setColor(0xff0000);
    g.fillArc(progress.getX(), progress.getY(), progressOverlayImage.getWidth(), progressOverlayImage.getHeight(), 0, currentProgress360);
});

You will need the following to get this to work.

  • You will need to update the percentage label when changing the progress value
  • You will need an "overlay image" that is transparent where you want the progress to appear
  • You will need a variable called currentProgress360 that will represent the current state of progress between 0 and 360
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!