Note that there are some explanatory texts on larger screens.

plurals
  1. POHorizontalScrollView inside ListView: minor vertical scroll stops horizontal scroll
    text
    copied!<p>In my example activity, I have<br> - a ListView containing<br> - multiple HorizontalScrollView containing<br> - a set of TextView </p> <p>The horizontal scrolling experience is rather bad though.<br> When I initiate a horizontal scroll (or fling), I must be very careful to make it work.</p> <p>As soon as the horizontal scroll contains a (small) vertical component, the vertical ListView scrolling takes over and stops the horizontal scrolling completely.</p> <p>Any suggestion on how to improve this?</p> <p>Thanks in advance,</p> <p>Marc</p> <pre><code>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 &lt; 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 &lt; 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); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload