Reputation: 553
I had some problem about scrolling with Card inside RecyclerView. There some additional gaps when I scroll inside the RecyclerView, you can see it in this gif:
This is my adapter. Is this because the fragment or what ?
public class PosItemAdapter extends RecyclerView.Adapter<PosItemAdapter.MyViewHolder> {
private List<Item> itemList;
private ArrayList<CartItem> cartList;
private Boolean isMixed = false;
public class MyViewHolder extends RecyclerView.ViewHolder {
public final View mView;
public ImageView picture;
public TextView name;
public TextView desc;
public TextView price;
public MyViewHolder(View view) {
super(view);
mView = view;
picture = (ImageView) view.findViewById(R.id.list_pos_item_picture);
name = (TextView) view.findViewById(R.id.list_pos_item_name);
price = (TextView) view.findViewById(R.id.list_pos_item_price);
}
}
public PosItemAdapter(ArrayList<Item> itemList, Boolean isMixed) {
this.itemList = itemList;
this.isMixed = isMixed;
}
public Item getValueAt(int position) {
return itemList.get(position);
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_pos_item_layout, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(final MyViewHolder holder, final int position) {
holder.mView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
@Override
public int getItemCount() {
if (itemList != null) {
return itemList.size();
} else {
return 0;
}
}
}
Upvotes: 2
Views: 2355
Reputation: 553
Solved, the problem was my card height. I set to wrap_content and the glitch fixed.
Upvotes: 1