0
public void onBindViewHolder(final ViewHolder viewHolder, final int position) {
    viewHolder.button.setText("button" + +position);    
    if(position == 0){
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams);
        viewHolder.button.getLayoutParams();
        params.height = 200;
        params.width = 200;
        viewHolder.itemView.setLayoutParams(params);
    }else{
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams);
        viewHolder.button.getLayoutParams();
        params.height = RecyclerView.LayoutParams.WRAP_CONTENT;
        params.width = RecyclerView.LayoutParams.WRAP_CONTENT;
        viewHolder.itemView.setLayoutParams(params);
    }
}

Using this code in the adapter of GridView I'm trying to give a custom size to the first item of GridView, but it changes size of all items in the row but items of other columns stay normal. So how can I make only 1 item to be changed in GridView?

Kar4
  • 25
  • 8

1 Answers1

0
if(position == 0){
    RecyclerView.LayoutParams params = (RecyclerView.LayoutParams);
    viewHolder.button.getLayoutParams();
    params.height = 200;
    params.width = 200;
    viewHolder.itemView.setLayoutParams(params);
}else{
   //make other item normal
}
justbebird
  • 13
  • 3