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

  • SEARCH
  • Home
  • 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 8611887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:29:14+00:00 2026-06-12T04:29:14+00:00

I want to create a custom gallery in which the center most view in

  • 0

I want to create a custom gallery in which the center most view in the gallery is showing a zoom out animation. So when I scroll my gallery, the items coming to the center will get zoomed. So what I need to know is :

  1. How can I find the center item in a gallery.(If 5 items are displayed, I need the 3rd item as center one).
  2. How can I animate it to get a smooth bulging effect when scrolling happens?
  • 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-06-12T04:29:15+00:00Added an answer on June 12, 2026 at 4:29 am

    With the help of a pipe kind of structure using queue, i got it when combined with addViewToLayout Method of Gallery.

    Code :

    Custom Gallery class

    public class NGallery extends Gallery {
    
    private Pipe<View> childViews;
    private int pipeSize;
    private View previousAnimatedView;
    private boolean isScrollLeft;
    
    public NGallery(Context context, AttributeSet attrs) {
        super(context, attrs);
        final Timer tmr = new Timer();
        TimerTask task = new TimerTask() {
    
            @Override
            public void run() {
                initialize();
                if (pipeSize > 0) {
                    tmr.cancel();
                }
            }
        };
        tmr.scheduleAtFixedRate(task, 100, 100);
    }
    
    private void initialize() {
        View childView = getChildAt(0);
        if (childView != null && childView.getWidth() > 0) {
            pipeSize = getWidth() / childView.getWidth();
            childViews = new Pipe<View>(pipeSize);
        }
    }
    
    @Override
    protected boolean addViewInLayout(View child, int index,
            android.view.ViewGroup.LayoutParams params,
            boolean preventRequestLayout) {
        View viewToAnimate = getViewToAnimate(child);
        if (viewToAnimate != null) {
            if (previousAnimatedView != null) {
                previousAnimatedView.clearAnimation();
            }
            viewToAnimate.requestFocus();
            AnimationSet animationSet = getAnimationSet(viewToAnimate);
            viewToAnimate.startAnimation(animationSet);
            previousAnimatedView = viewToAnimate;
        }
        return super
                .addViewInLayout(child, index, params, preventRequestLayout);
    }
    
    @Override
    public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
            float distanceY) {
        isScrollLeft = distanceX > 0;
        return super.onScroll(e1, e2, distanceX, distanceY);
    }
    
    private AnimationSet getAnimationSet(View viewToAnimate) {
        AnimationSet animationSet = new AnimationSet(false);
    
        Animation scaleAnimation = new ScaleAnimation(1, 1.5f, 1, 1.5f);
        scaleAnimation.setDuration(100);
        animationSet.addAnimation(scaleAnimation);
    
        Animation transAnimation = new TranslateAnimation(0, 0, 0, 25);
        transAnimation.setDuration(100);
        animationSet.addAnimation(transAnimation);
    
        animationSet.setFillAfter(true);
    
        return animationSet;
    }
    
    private View getViewToAnimate(View child) {
        if (childViews != null) {
            if (isScrollLeft) {
                childViews.addFirst(child);
            } else {
                childViews.addLast(child);
            }
            return childViews.getCenterItem();
        } else {
            return null;
        }
    }
    
    }
    

    Pipe class :

    public class Pipe<E> {
    
    private LinkedList<E> list;
    private int pipeSize;
    
    public Pipe(int size) {
        list = new LinkedList<E>();
        pipeSize = size;
    }
    
    public E getItemAt(int position) {
        return list.get(position);
    }
    
    public E getCenterItem() {
        int pos = pipeSize / 2;
        if (pos < list.size()) {
            return list.get(pos);
        } else {
            return null;
        }
    }
    
    public void addFirst(E item) {
        if (list.size() >= pipeSize) {
            list.removeLast();
        }
        list.addFirst(item);
    }
    
    public void addLast(E item) {
        if (list.size() >= pipeSize) {
            list.removeFirst();
        }
        list.addLast(item);
    }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a custom alert view within my iOS application. For example,
I want to create custom templated control which controls inside of template coluld be
I want to create custom Toast view like public class SMSToast extends Activity {
I want to create custom shaped window. I only need to specify which pixels
i want create a custom json data from the mssql 2008 results so that
I want to create custom button and I need it to be circle. How
I want to create a custom navigation bar to put in my header.phtml file.
I want to create a custom set that will automatically convert objects into a
I want to create a custom property on one of my entities mapped from
I want to create a custom list in Flex for an interface prototype. The

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.