0
我在android中設置了數據綁定片段的背景。由於後臺可以動態改變我設置它在這樣的XML:使用數據綁定設置背景圖像閃爍
app:image="@{variable.getBackgroundImage()}"
的getBackgroundImage()將給背景的路徑。 我使用滑行設置這樣的背景:
Glide.with(view.getContext()).load(url + File.separator + path)
.dontAnimate()
.into(new SimpleTarget<GlideDrawable>() {
@Override
public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
view.setBackground(resource);
}
});
圖像是越來越設置,但沒有在XML中預先設定背景的瞬間閃爍。
我該如何避免這種閃爍的背景?
我只能想到兩件事情:Glide需要一些時間來加載資源,或者你沒有運行executePendingBindings() –