Android Resize selected item in GridView

626 Views Asked by At

I have a grid view displaying a number of ImageView with different background colors. Is it possible to scale just the selected item without affecting the placement of the other items in the GridView? Something like below?

Scale selected item

I have tried setting the layout params on the underlying view that is returned when an item is clicked, but that seems to be chopping off part of the resized item and it not centering the selected item.

   int newDimension = Utility.dpToPx(100);
   float measuredWidth = view.getMeasuredWidth();
   float measuredHeight = view.getMeasuredHeight();

   GridView.LayoutParams layoutParams = (GridView.LayoutParams) view.getLayoutParams();
   view.setPivotX(newDimension / 2);
   view.setPivotY(newDimension / 2);
   layoutParams.width = newDimension;
   layoutParams.height = newDimension;
   view.setLayoutParams(layoutParams);
1

There are 1 best solutions below

1
On

close try calling, gridView.getItemAtPosition(position) and it will return your view do your operation then