Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 890319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:42:50+00:00 2026-05-15T13:42:50+00:00

When I use the Gallery widget , how do I get the images to

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:42:50+00:00Added an answer on May 15, 2026 at 1:42 pm

    Hope this is helpful. I manage to “simulate” the shrink/grow solution with the Gallery widget. Since they removed the getScale(), 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 Gallery manages the focus EXTREMELY BAD. So, the first approach was to add a focus change listener on the ImageView displayed, 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 the focusSearch()method and some focus contants).

    Here’s my solution to this problem:

    Build an animation resource to ‘grow’ the image:

    <?xml version="1.0" encoding="utf-8"?>
    <scale xmlns:android="http://schemas.android.com/apk/res/android"
           android:fromXScale="1.0"
           android:toXScale="1.10"
           android:fromYScale="1.0"
           android:toYScale="1.10"
           android:duration="300"
           android:pivotX="50%"
           android:pivotY="50%"
           android:interpolator="@android:anim/accelerate_decelerate_interpolator"
           android:fillAfter="false"/>
    

    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.xml or whatever name it suites you (but always in res/anim dir).

    You can follow the resource guide from here to create a Gallery view. The ImageAdapter builds an ImageView every time that the Gallery object calls getView(). One workaround you could implement is adding a line to the getView() method that identifies a View with a position, this way:

    ...
    i.setId(position);
    ...
    

    With that line added to the getView() method of the ImageAdpater object, you can then unequivocally identify that view within a listener, for instance:

    g.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void  onItemSelected  (AdapterView<?>  parent, View  v, int position, long id) {
            Animation grow = AnimationUtils.loadAnimation(YourActivity.this, R.anim.grow);
    
            View sideView = parent.findViewById(position - 1);
            if (sideView != null)
               ((ImageView)sideView).setLayoutParams(new Gallery.LayoutParams(150, 100));
    
            sideView = parent.findViewById(position + 1);
            if (sideView != null)
               ((ImageView)sideView).setLayoutParams(new Gallery.LayoutParams(150, 100));
    
            v.startAnimation(grow);
            v.setLayoutParams(new Gallery.LayoutParams(170, 150));
        }
    
        public void  onNothingSelected  (AdapterView<?>  parent) {
            System.out.println("NOTHING SELECTED");
    
        }
        });
    

    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 the getView() method:

    private class SelectListener implements AdapterView.OnItemSelectedListener {
         private Animation grow;
         private int last;
    
         public SelectListener() {
            grow = AnimationUtils.loadAnimation(RouteGallery.this, R.anim.grow);
            last = 0;
         }
    
         public void  onItemSelected  (AdapterView<?>  parent, View  v, int position, long id) {
            View sideView = parent.findViewById(last);
            if (sideView != null && last != position)
               sideView.clearAnimation();
    
            v.startAnimation(grow);
            last = position;
         }
    
        public void  onNothingSelected  (AdapterView<?>  parent) {
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.