{"action":"created","issue":{"url":"https://api.github.com/repos/bumptech/glide/issues/729","labels_url":"https://api.github.com/repos/bumptech/glide/issues/729/labels{/name}","comments_url":"https://api.github.com/repos/bumptech/glide/issues/729/comments","events_url":"https://api.github.com/repos/bumptech/glide/issues/729/events","html_url":"https://github.com/bumptech/glide/issues/729","id":115236982,"number":729,"title":"ImageView flickering issue","user":{"login":"SeanOceanHu","id":3882561,"avatar_url":"https://avatars.githubusercontent.com/u/3882561?v=3","gravatar_id":"","url":"https://api.github.com/users/SeanOceanHu","html_url":"https://github.com/SeanOceanHu","followers_url":"https://api.github.com/users/SeanOceanHu/followers","following_url":"https://api.github.com/users/SeanOceanHu/following{/other_user}","gists_url":"https://api.github.com/users/SeanOceanHu/gists{/gist_id}","starred_url":"https://api.github.com/users/SeanOceanHu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SeanOceanHu/subscriptions","organizations_url":"https://api.github.com/users/SeanOceanHu/orgs","repos_url":"https://api.github.com/users/SeanOceanHu/repos","events_url":"https://api.github.com/users/SeanOceanHu/events{/privacy}","received_events_url":"https://api.github.com/users/SeanOceanHu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-11-05T09:00:03Z","updated_at":"2015-11-05T12:19:45Z","closed_at":null,"body":"Hi guys,\r\nWe are using Glide to load pictures/gifs in our app, but we are having a flickering issue.\r\n\r\nBasically we used a RecyclerView to display a list of card(a news card to be specific, which contains both text and image/gif), in each card-view's instantiation method we would create TextViews or ImageViews in a for loop and add them to the card-view's LinearLayout. The problem is that when we try to use Glide to load images into ImageView, flikering would happen. Here's the codes:\r\n\r\nthe image item's layout \r\n```\r\n<ImageView xmlns:android=\"http://schemas.android.com/apk/res/android\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"wrap_content\"\r\n    android:layout_marginBottom=\"5dp\"\r\n    android:layout_marginLeft=\"12dp\"\r\n    android:layout_marginRight=\"12dp\"\r\n    android:scaleType=\"centerCrop\"\r\n    android:adjustViewBounds=\"true\"\r\n    android:layout_centerInParent=\"true\"\r\n    android:src=\"@drawable/image_loading_placeholder\" >\r\n</ImageView>\r\n```\r\n\r\nHow we load images using Glide:\r\n```\r\nGlide.with(context)\r\n        .load(imageUrl)\r\n        .error(R.drawable.image_loading_placeholder)\r\n        .placeholder(R.drawable.image_loading_placeholder)\r\n        .diskCacheStrategy(DiskCacheStrategy.ALL)\r\n        .transform(new MaxHeightResizeTransformation(activity, scaledUrl))\r\n        .into(v);\r\n```\r\n\r\nDo you guys have any clues on this issue ? Would really appreciate your help : )\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/bumptech/glide/issues/comments/154043851","html_url":"https://github.com/bumptech/glide/issues/729#issuecomment-154043851","issue_url":"https://api.github.com/repos/bumptech/glide/issues/729","id":154043851,"user":{"login":"TWiStErRob","id":2906988,"avatar_url":"https://avatars.githubusercontent.com/u/2906988?v=3","gravatar_id":"","url":"https://api.github.com/users/TWiStErRob","html_url":"https://github.com/TWiStErRob","followers_url":"https://api.github.com/users/TWiStErRob/followers","following_url":"https://api.github.com/users/TWiStErRob/following{/other_user}","gists_url":"https://api.github.com/users/TWiStErRob/gists{/gist_id}","starred_url":"https://api.github.com/users/TWiStErRob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TWiStErRob/subscriptions","organizations_url":"https://api.github.com/users/TWiStErRob/orgs","repos_url":"https://api.github.com/users/TWiStErRob/repos","events_url":"https://api.github.com/users/TWiStErRob/events{/privacy}","received_events_url":"https://api.github.com/users/TWiStErRob/received_events","type":"User","site_admin":false},"created_at":"2015-11-05T12:19:45Z","updated_at":"2015-11-05T12:19:45Z","body":"Glide uses a ViewTreeObserver listener to wait for layout: please try to set up the view hierarchy fully, before loading image into it; not necessarily the problem, just a curtesy to Glide. Who knows, it may help. You could simply use `inflate(R.layout...., holder.linearLayoutParent, true)`.\r\n\r\nYou didn't describe the flicker, please expand on that. Regardless, if you use `holder.linearLayoutParent.removeAllViews()` to reset the card in bind, consider using this in your adapter instead to reset a card:\r\n```java\r\n@Override public void onViewRecycled(VH holder) {\r\n\tViewGroup p = holder.linearLayoutParent;\r\n\tint count = p.getChildCount();\r\n\tfor (int i = 0; i < count; i++) {\r\n\t \t// optionally you can check `if (child instanceof ImageView)` if you have many children\r\n\t \t// but Glide should handle non-loaded/non-image Views\r\n\t\tGlide.clear(p.getChildAt(i)); // stop loading and get rid of loaded image\r\n\t}\r\n\tp.removeAllViews();\r\n}\r\n```\r\nThis is more likely to help than having the View in the hierarchy before `into`.\r\n\r\nPerformance may not be an issue with removeAll/inflate, it's more the battery consumption; just because a device is fast enough it doesn't mean it has to be utilized more than necessary."}}