【发布时间】:2018-11-29 14:52:10
【问题描述】:
我必须在线性布局中将 GIF 图像设置为背景。我正在使用以下代码
final LinearLayout layoutMain = (LinearLayout) findViewById(R.id.main_layout);
Glide.with(this).load(R.raw.game_screen_background)
.into(new SimpleTarget<Drawable>() {
@Override
public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
layoutMain.setBackground(resource);
}
});
但它没有将 GIF 设置为背景。 GIF 在 raw 文件夹中,我正在使用下面的 glide 依赖项
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
为什么 GIF 没有加载?我错过了什么吗?
【问题讨论】:
-
你调试过你的代码吗?也许它抛出了一些异常/错误。 ?
-
不会进入 onResourceReady 但没有将背景设置为线性布局
标签: android gif android-glide