fix item's width and height were replaced by default params.

This commit is contained in:
skycrown
2020-05-13 22:28:42 +08:00
parent f394eff9be
commit 54687a7eb5
2 changed files with 9 additions and 2 deletions
+1 -1
View File
@@ -44,7 +44,7 @@
GROUP=com.alibaba.android
ARTIFACT=vlayout
VERSION=1
VERSION_NAME=1.2.38
VERSION_NAME=1.2.39
PACKAGING_TYPE=aar
useNewSupportLibrary=true
systemProp.compileSdkVersion=26
@@ -81,7 +81,14 @@ public abstract class RecyclablePagerAdapter<VH extends RecyclerView.ViewHolder>
//so the attributes of layoutParam such as widthFactor and position will also be reused,
//while these attributes should be reset to default value during reused.
//Considering ViewPager.LayoutParams has a few inner attributes which could not be modify outside, we provide a new instance here
container.addView(holder.itemView, new ViewPager.LayoutParams());
ViewPager.LayoutParams layoutParams = new ViewPager.LayoutParams();
if (holder.itemView.getLayoutParams() != null) {
layoutParams.width = holder.itemView.getLayoutParams().width;
layoutParams.height = holder.itemView.getLayoutParams().height;
}
container.addView(holder.itemView, layoutParams);
return holder;
}