1

I am using list view inside of the scroll view but the problem is scroll view is scrolling but list view is not scrolling.

Cœur
  • 32,421
  • 21
  • 173
  • 232
Baskar
  • 31
  • 3
  • possible duplicate of [Listview inside ScrollView is not scrolling on Android](http://stackoverflow.com/questions/6210895/listview-inside-scrollview-is-not-scrolling-on-android) – richq Jun 13 '11 at 11:31
  • Or alternatively: possible duplicate of http://stackoverflow.com/questions/5415011/android-listview-inside-a-scrollview – richq Jun 13 '11 at 11:31
  • Or maybe: possible duplicate of http://stackoverflow.com/questions/4965798/how-to-scroll-listview-with-in-another-scroll-view – richq Jun 13 '11 at 11:32

2 Answers2

0

override listview onMeasure method

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
    MeasureSpec.AT_MOST);
    super.onMeasure(widthMeasureSpec,expandSpec);
}
0

Use the following method and enjoy!

    private void setListViewScrollable(final ListView list) {
    list.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            listViewTouchAction = event.getAction();
            if (listViewTouchAction == MotionEvent.ACTION_MOVE)
            {
                list.scrollBy(0, 1);
            }
            return false;
        }
    });
    list.setOnScrollListener(new OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView view,
                int scrollState) {
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem,
                int visibleItemCount, int totalItemCount) {
            if (listViewTouchAction == MotionEvent.ACTION_MOVE)
            {
                list.scrollBy(0, -1);
            }
        }
    });
}

listViewTouchAction is a global integer value. If you can replace the line

list.scrollBy(0, 1);

with something else please share it with us.

Bobs
  • 21,870
  • 33
  • 134
  • 221