I have the same issue as this post.
http://i.imgur.com/FUapm2K.gif?1
StaggeredGridLayoutManager and moving items
However i can't understand the answer, here is the method i am calling inside the OnBindViewHolder()
method of my adapter.
private void setRealSize(Post post, int position) {
Log.d(TAG, "setRealSize: width " + post.getWidthPost());
Log.d(TAG, "setRealSize: height : " + post.getHeightPost());
int percentWidth = (maxWidth / 3);
double scaleFactor = (double) percentWidth / (double) post.getWidthPost();
Log.d(TAG, "setRealSize: factor " + scaleFactor);
Log.d(TAG, "setRealSize: height " + scaleFactor * post.getHeightPost());
picturePreview.getLayoutParams().width = percentWidth;
picturePreview.getLayoutParams().height = (int) (scaleFactor * post.getHeightPost());
}
My pictures are perfectly resized and keep their original aspect ratio. But i got the moving bug when i scroll up again...
And even if i would "store" these values for each picture, where and how should i use these values again if not with getLayoutParams().height
?
in my Fragment
which contains the recycler view i only have for the StaggeredGridLayoutManager the following line of code :
gridLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
Even if i remove the DefaultAnimator
we can still see the change even if it's done much faster, it's quite ugly.
Thanks