[英]How to change First item height in RecyclerView?
I'm having troubles with the recyclerView, I have two rows (like Pinterest) full of images but when I try to change the First image height the other images are pushed to the right and look like in this problem: StaggeredGridLayoutManager: Adding Margin makes the layout items pushed to the side我在使用 recyclerView 时遇到问题,我有两行(如 Pinterest)充满了图像,但是当我尝试更改第一个图像高度时,其他图像被推到右侧,看起来像这个问题: StaggeredGridLayoutManager:添加边距使布局项目推到一边
That happens when I do this:当我这样做时会发生这种情况:
@Override
public void onBindViewHolder(ViewHolder viewHolder, int i) {
// setting image resource
if(i ==0){
viewHolder.imgview.getLayoutParams().height = 250; //THIS LINE CAUSE ME PROBLEMS
viewHolder.imgview.requestLayout();
}
OtherClass.loadImage(Image.get(i),viewHolder.imgview);
}
So, how can I change the first image height and not having that problem?那么,我怎样才能改变第一个图像的高度而没有这个问题呢?
I'm having troubles with the recyclerView, I have two rows (like Pinterest) full of images but when I try to change the First image height the other images are pushed to the right and look like in this problem: StaggeredGridLayoutManager: Adding Margin makes the layout items pushed to the side我在使用 recyclerView 时遇到问题,我有两行(如 Pinterest)充满了图像,但是当我尝试更改第一个图像高度时,其他图像被推到右侧,看起来像这个问题: StaggeredGridLayoutManager:添加边距使布局项目推到一边
That happens when I do this:当我这样做时会发生这种情况:
@Override
public void onBindViewHolder(ViewHolder viewHolder, int i) {
// setting image resource
if(i ==0){
viewHolder.imgview.getLayoutParams().height = 250; //THIS LINE CAUSE ME PROBLEMS
viewHolder.imgview.requestLayout();
}
OtherClass.loadImage(Image.get(i),viewHolder.imgview);
}
So, how can I change the first image height and not having that problem?那么,我怎样才能改变第一个图像的高度而没有这个问题呢?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.