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 8339775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:58:28+00:00 2026-06-09T04:58:28+00:00

How to make horizontalscrollview that move relatively object that is closer to the screen

  • 0

How to make horizontalscrollview that move relatively object that is closer to the screen center?
Like in the picture:

enter image description here

  • 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-09T04:58:30+00:00Added an answer on June 9, 2026 at 4:58 am

    I find solution in the news-parser example. My code:

    ….

    gestureDetector = new GestureDetector(new MyGestureDetector());
            hs = (HorizontalScrollView) findViewById(R.id.hs);
            hs.setOnTouchListener(new OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (gestureDetector.onTouchEvent(event)) {
                        return true;
                    }
                    if (event.getAction() == 1)
                    {
                        if (hs.getScrollX() > mWidth * 8 + mWidth / 2)
                        {
                            hs.smoothScrollBy(mWidth * 9 - hs.getScrollX(), 0);
                        }
                        else if (hs.getScrollX() > mWidth * (cN - 2)  + mWidth / 2)
                        {
                            hs.smoothScrollBy(mWidth * (cN - 1) - hs.getScrollX(), 0);
                        }
                        else if (hs.getScrollX() > mWidth / 2)
                        {
                            hs.smoothScrollBy(mWidth - hs.getScrollX(), 0);
                        }
                        else
                        {
                            hs.smoothScrollBy(-hs.getScrollX(), 0);
                        }
                        return true;
                    }
                    return false;
                }
            });
        }
    
    
        class MyGestureDetector extends SimpleOnGestureListener {
    
            @Override
            public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
                    float velocityY) {
                //Log.v("e1.getX()", Float.toString(e1.getX()));
                //Log.v("e2.getX()", Float.toString(e2.getX()));
                //Log.v("velocityX", Float.toString(velocityX));
                if (velocityX > 0) {
                    moveLeft();
                } else {
                    moveRight();
                }
                return true;
            }
        }
    
        private void moveRight() {
            if (hs.getScrollX() > 0 && hs.getScrollX() < mWidth * cN)
            {
                hs.smoothScrollBy(mWidth * cN - hs.getScrollX(), 0);
                cN++;
            }
            //Log.v("cN", Integer.toString(cN));
        }
    
        private void moveLeft() {
    
            if (hs.getScrollX() > 0 && hs.getScrollX() < mWidth)
            {
                hs.smoothScrollBy( -hs.getScrollX(), 0);
                cN = 1;
            }
            else if (hs.getScrollX() > mWidth && hs.getScrollX() < mWidth * (cN - 1) )
            {
                hs.smoothScrollBy(mWidth * (cN - 2) - hs.getScrollX(), 0);
                cN--;
            }
            //Log.v("cN", Integer.toString(cN));
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to make horizontalscrollview scroll-line invisible?
I make a picture with phone (640*480) and put it inside uiimageview (300*300) with
I make an app that have to printing image. I need to print image
SOLUTION Make sure in the plist that the storyboard name is listed as the
I make some script, that have modal window on fancybox and on load it's
I make a j2me application that almost all of it, are text files. size:
Make something like in html/css
Want make a mind map like the following: Image link is not available anymore.
I make a graph with three.js and I would like to connect the nodes
Make javaScript and CSS External Source . Does that mean I should use JavaScript

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.