How can I show animated GIFs in this library?

huangapple go评论65阅读模式
英文:

How can I show animated GIFs in this library?

问题

我应该显示带有这个库的动画GIF吗?下面的代码只显示GIF的静态版本,而不是动态版本。

addSlide(new SimpleSlide.Builder()
        .title("这应该是一个动画GIF")
        .image(R.drawable.animated_gif)
        .build());

我已经查看了Glide,但我不确定如何在这种情况下使用它。

英文:

How can I display animated GIFs with this library ?
The code below only shows a static version of the GIF not a moving one.

    addSlide(new SimpleSlide.Builder()
            .title("This is supposed to be an animated GIF")
            .image(R.drawable.animated_gif)
            .build());

I have taken a look at Glide but I'm not sure how to use it in this case.

答案1

得分: 4

你可以使用Glide来加载你的gif动画,所以在你的gradle文件中添加以下依赖项:

implementation 'com.github.bumptech.glide:glide:4.3.1'

然后在你的活动中像下面这样使用它:

Glide.with(this/*你的上下文*/).load(R.drawable.animated_gif).into((ImageView)findViewById(R.id.ImageViewId));
英文:

You may use glide to load your gif, so in your gradle have this inside your dependancies

  implementation 'com.github.bumptech.glide:glide:4.3.1'

then in your activity use it like below

Glide.with(this\*your context*\).load(R.drawable.animated_gif).into((ImageView)findViewById(R.id.ImageViewId));

答案2

得分: 0

不可能使用Material intro来实现这个。考虑使用另一个库,比如pl.droidsonroids.gif:android-gif-drawable。在你的Gradle文件中添加以下依赖:

implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'

然后在你的XML布局文件中使用以下代码:

<pl.droidsonroids.gif.GifImageView
    android:id="@+id/gif_view"
    android:layout_width="40dp"
    android:layout_height="44dp"
    android:scaleType="fitXY"
    android:src="@drawable/yourgif">

希望这对你有帮助。

英文:

No its not possible with Material intro.Consider using another library like pl.droidsonroids.gif:android-gif-drawable
on your Gradle have implementation &#39;pl.droidsonroids.gif:android-gif-drawable:1.2.19&#39;

Then on your xml

&lt;pl.droidsonroids.gif.GifImageView
    android:id=&quot;@+id/gif_view&quot;
    android:layout_width=&quot;40dp&quot;
    android:layout_height=&quot;44dp&quot;
    android:scaleType=&quot;fitXY&quot;
    android:src=&quot;@drawable/yourgif&quot;&gt;

答案3

得分: 0

你为什么不只是使用ImageView插入GIF图像?您可以按照这里的说明进行操作:链接

英文:

Why don't you just insert GIFS with ImageView? You can follow instructions here.

答案4

得分: 0

使用Glide

Glide.with(this)
.asGif()
.load("gifSourse")
.into(targetImageView);

英文:

Using Glide

Glide.with(this)
.asGif()
.load(&quot;gifSourse&quot;)
.into(targetImageView);

huangapple
  • 本文由 发表于 2020年7月22日 23:26:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/63037794.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定