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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:44:53+00:00 2026-05-27T15:44:53+00:00

In my example activity, I have – a ListView containing – multiple HorizontalScrollView containing

  • 0

In my example activity, I have
– a ListView containing
– multiple HorizontalScrollView containing
– a set of TextView

The horizontal scrolling experience is rather bad though.
When I initiate a horizontal scroll (or fling), I must be very careful to make it work.

As soon as the horizontal scroll contains a (small) vertical component, the vertical ListView scrolling takes over and stops the horizontal scrolling completely.

Any suggestion on how to improve this?

Thanks in advance,

Marc

import android.app.Activity;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class Test extends Activity 
{
private final static int N = 20;//number of HorizontalScrollView
private final static int M = 20;//number of TextViews inside a single HorizontalScrollView


@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    //create a list of HorizontalScrollViews
    final HorizontalScrollView[] hors = new HorizontalScrollView[N];
    for (int i = 0; i < hors.length; i++)
    {
        hors[i] = new HorizontalScrollView(this, null);
        hors[i].setMinimumHeight(60);
        LinearLayout ll = new LinearLayout(this);
        ll.setOrientation(LinearLayout.HORIZONTAL);
        hors[i].addView(ll);
        for (int j = 0; j < M; j++)
        {
            TextView t = new TextView(Test.this);
            t.setText("HorizontalScrollView: "+i+"; TextView: "+j);
            t.setMinimumHeight(40);
            ll.addView(t);
        }
    }
    //add a ListView
    ListView list = new ListView(this);
    layout.addView(list);
    list.setAdapter(new BaseAdapter()
    {

        @Override
        public View getView(int position, View convertView, ViewGroup parent)
        {
            return hors[position];
        }

        @Override
        public long getItemId(int position)
        {
            return 0;
        }

        @Override
        public Object getItem(int position)
        {
            return hors[position];
        }

        @Override
        public int getCount()
        {
            return N;
        }
    });

    setContentView(layout);

}


}
  • 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-27T15:44:53+00:00Added an answer on May 27, 2026 at 3:44 pm

    The problem is that ListView (or rather its parent AbsListView) implements onInterceptTouchEvent and hence ListView can intercept all touch events as soon as it considers it is in a better position to handle them.

    This can be avoided by calling requestDisallowInterceptTouchEvent, e.g. by subclassing HorizontalScrollView and in its dispatchTouchEvent:

    public boolean dispatchTouchEvent(MotionEvent ev)
    {
      boolean ret = super.dispatchTouchEvent(ev);
      if(ret) 
      {
        requestDisallowInterceptTouchEvent(true);
      }
      return ret;
    }       
    

    It needs some refinement (like only call requestDisallowInterceptTouchEvent if the horizontal component is larger than the vertical one) since now it hardly ever allows the ListView to take control.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 classes in my example: Class A, the main activity. Class A
I have an activity defined as below: <activity android:name=com.example.ui.HomeActivity android:alwaysRetainTaskState=true/> A strange thing is
I have an activity that extends ListView. I populate my list with the results
I have this menu example But in this example new activity is not called,
I have service, widget and activity....widget and activity both have one textview which should
I have main activity which call other object, for example GPS class. This GPS
I have an activity which is called by a few other activities. For example,
In my activity I have for example SQLiteDatabase db = openOrCreateDatabase(Preferences.DB_NAME, Context.MODE_PRIVATE, null); db.execSQL(CREATE
I have created a an activity named Example which have 3 LinearLayouts . I
I have 1 activity, but would like to have multiple context menu's for different

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.