首页 文章

背景图像缩放和容器codenameone中心

提问于
浏览
1

我试图使用设置容器缩放的背景,并在中心覆盖coontainer的一些protion . 当我使用如下的普通图像 . 它工作正常,但图像覆盖整个容器 .

Image img = URLImage.createToStorage(placeHolder, url, url, URLImage.RESIZE_SCALE);
findContainerMain(f).setUIID("ContainerBgImage");
findContainerMain(f).getStyle().setBackgroundType(Style.BACKGROUND_IMAGE_SCALED,true);
findContainerMain(f).getStyle().setBgImage(img, true);

但是当我使用缩放图像作为背景时,它不会显示任何图像只是白色背景 .

Image img = URLImage.createToStorage(placeHolder, url, url, URLImage.RESIZE_SCALE).scaledHeight(50);
findContainerMain(f).setUIID("ContainerBgImage");
findContainerMain(f).getStyle().setBackgroundType(Style.BACKGROUND_IMAGE_SCALED,true);
findContainerMain(f).getStyle().setBgImage(img, true);

我怎样才能获得所需的效果 .

1 回答

  • 0

    URLImage是懒惰地获取的,并依赖于图像的动画属性来更新自身 .

    scaled 方法创建一个全新的图像对象,该对象没有与 URLImage 关联的提取属性 .

相关问题