سؤال

I have a GridView in which I would like to handle onItemClick events by fading out all items except the item clicked.

However, with my current method of attempting this:

adapterView.animate().setDuration(250).alpha(0);
clickedView.clearAnimation();

clickedView fades with the rest of adapterView. I suspect this is because the animation is setting alpha on the entire GridView container, rather than its individual children.

I am looking for at least a somewhat elegant workaround to this problem. I could probably just iterate through all the visible children and have them each individually fade, but I feel like there is probably something smarter and simpler than that.

هل كانت مفيدة؟

المحلول

I think you're on the right track.

Try creating a new View as a copy of the clickedView, setting all of the properties including height, width, etc. as well as position.

Then show the clickedView, and hide the adapterView as you are.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top