When I use the Gallery widget, how do I get the images to say scale up & glow on being selected and scaled down & un-glow on being unselected?
All tutorials I’ve seen have this effect but I’m not able to see it…
Is there some kind of an animation that I have to attach to the Gallery?
Hope this is helpful. I manage to “simulate” the shrink/grow solution with the
Gallerywidget. Since they removed thegetScale(), things get a little bit complicated. I think that this it’s not the best solution at all, but at least I can live with it.What I have found is that
Gallerymanages the focus EXTREMELY BAD. So, the first approach was to add a focus change listener on theImageViewdisplayed, but no luck there. Focus is a MESS there… in terms that, the selected image it’s not the currently focused view. I have sent a mail to android-developers mailing list about some error on API doc (regarding thefocusSearch()method and some focus contants).Here’s my solution to this problem:
Build an animation resource to ‘grow’ the image:
If you don’t get what that means then you should proceed to read this
That will be our ‘grow’ effect, and you will need to save it in:
res/anim/grow.xmlor whatever name it suites you (but always in res/anim dir).You can follow the resource guide from here to create a
Galleryview. TheImageAdapterbuilds anImageViewevery time that theGalleryobject callsgetView(). One workaround you could implement is adding a line to thegetView()method that identifies aViewwith aposition, this way:With that line added to the
getView()method of theImageAdpaterobject, you can then unequivocally identify that view within a listener, for instance:NOTE: You may notice that all the values from animation and from layout parameters has been choosen by me at hand. This is because i’m not going to clean code for you. And, this is just a workaround the BAD focus issue with this widget or the android view system. If focus were OK, then, all you need to do is set a focus change listener that makes the gros/shrink when it got focus/unfocused.
I hope this may help you to find a way around for your problem,
Regards,
New EDIT: This is the listener I have set, I also added the line
i.clearAnimation()in thegetView()method: