【问题标题】:How to set animated image (gif) in a SWT widget using Tabris Framework如何使用 Tabris 框架在 SWT 小部件中设置动画图像 (gif)
【发布时间】:2014-09-26 09:33:15
【问题描述】:

我需要在应用程序中显示动画 gif 图像。在以下代码示例中,我设置了 Label 小部件的 setImage 属性。这在浏览器(说唱)中运行良好,但移动应用程序仅显示没有动画的静态图像。有没有办法使用 Tabris 框架显示动画图像?

private void openDialog() {
    this.display = getUI().getDisplay();
    this.shell = new Shell( this.display, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL );
this.shell.setLayout( new GridLayout() );        

    Image image = createImage( this.display, "resources/loading.gif" );
    Label label = new Label( this.shell, SWT.NONE );
    label.setImage( image );

    this.shell.open();
}


private Image createImage( Display display, String resourceName ) {
    ClassLoader classLoader = getClass().getClassLoader();
    InputStream inputStream = classLoader.getResourceAsStream( resourceName );
    if( inputStream == null ) {
        throw new IllegalArgumentException( "Resource not found: " + resourceName );
    }
    try {
        return new Image( display, inputStream );
    } finally {
        try {
            inputStream.close();
        } catch( IOException exception ) {
            // TODO handle exception
        }
    }
}

【问题讨论】:

    标签: tabris


    【解决方案1】:

    目前无法显示动画 gif。 Tabris 将改进对图像显示的支持,以便将来添加该功能。

    【讨论】:

      猜你喜欢
      • 2023-03-25
      • 1970-01-01
      • 1970-01-01
      • 2014-12-26
      • 1970-01-01
      • 1970-01-01
      • 2010-10-07
      • 2019-07-15
      • 2016-11-17
      相关资源
      最近更新 更多