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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:16:22+00:00 2026-06-16T06:16:22+00:00

I have a simple layout with HorizontalScrollView and horizontal-LinearLayout, like this: <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent

  • 0

I have a simple layout with HorizontalScrollView and horizontal-LinearLayout, like this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:scrollbars="horizontal"
        android:fadingEdge="none">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="horizontal">

            <TextView
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sed velit sed nisl pharetra consequat"/>
            <TextView
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sed velit sed nisl pharetra consequat"/>
            <TextView ... (same text view repeated several times) />

        </LinearLayout>

    </HorizontalScrollView>

</RelativeLayout>

When I test this on the emulator, horizontal-fling works great. But testing it on a Samsung Galaxy S2, fling behaves in a strange way:

When the finger moves to-side-and-up, the scroll view starts flinging ok, but before stopping, it bounces and moves back, although it has NOT reached the end. It is as the scrollview is bouncing at any scroll level.

If I just scroll (move the finger to-side-stop-and-up), scroll is done OK.

Has anyone experienced this? Is it any bug in Samsung implementation?

Any ideas on how to fix this?

My app is targeting android 2.2.
Galaxy S2 has official Samsung android 4.0.3.

Thanks in advance!

  • 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-16T06:16:24+00:00Added an answer on June 16, 2026 at 6:16 am

    After lots of tests I have come to the conclusion that it is a bug on Samsung firmware (Galaxy S2 4.0.3), on HorizontalScrollView.

    It seems that the fling-gesture is being made to the opposite direction that it should:
    For example, if I press and move to the left, and release the screen, the fling-effect (continue moving and speed down) is done to the… RIGHT!

    So my solution has been subclassing HorizontalScrollView, and add a patch to make sure that if the scroll is done to the right, fling is to the right, and viceversa.

    public class PatchedHorizontalScrollView extends HorizontalScrollView {
        public PatchedHorizontalScrollView(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
        }
        public PatchedHorizontalScrollView(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
        public PatchedHorizontalScrollView(Context context) {
            super(context);
        }
    
        // store most recent scroll X positions
        int olderScrollX = 0;
        int lastScrollX = 0;
    
        @Override
        public boolean onTouchEvent(MotionEvent ev) {
            // keep track of most recent scroll positions
            olderScrollX = lastScrollX;
            lastScrollX = getScrollX();
    
            return super.onTouchEvent(ev);
        }
    
        @Override
        public void fling(int velocityX) {
            // ensure velocityX has the right sign
            if (lastScrollX > olderScrollX) {
                // to the right: velocity must be positive
                if (velocityX < 0) {
                    velocityX = -velocityX;
                }
            } else if (lastScrollX < olderScrollX) {
                // to the left: velocity must be negative
                if (velocityX > 0) {
                    velocityX = -velocityX;
                }
            }
    
            super.fling(velocityX);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple layout: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical >
I have a quite simple layout: <?xml version=1.0 encoding=utf-8?> <!-- --> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/dialog_progress
I have simple layout: <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent android:layout_height=match_parent > <GridView android:id=@+id/photo_browser_grid_view
I have a simple layout: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent> <LinearLayout
I have the following simple layout <?xml version=1.0 encoding=utf-8?> <ScrollView xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=wrap_content >
I have a rather simple ListView row: <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=wrap_content
I have simple WebView code like this: WebView wv = (WebView) findViewById(R.id.webview1); wv.loadUrl(http://en.wikipedia.org/wiki/Book); But
I have fairly simple layout, like this: <div class=card> <span class=attack>1</div> <span class=defence>2</div> </div>
I have created a simple layout using the HTML div tag. I would like
I have to make a simple layout in android but have problem with 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.