2

I use a GridView in a ScrollView. As we all know,there must be some problems. So I use a Class extends GridView,and Override the onMeasure method with:

int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);   
super.onMeasure(widthMeasureSpec, expandSpec);   

Thus the gridview problem can be resolved using Android 2.2 SDK. And the gridview can be focused Normally anyway.

My Question is : When I use Android 4.0 SDK, the problem is : I use that extended GridView in a ScrollView as well.The ScrollView is filling the parent. When the size of GridView is smaller than the existing ScrollView, the GridView can get the focus by touching it normally. However,when the number of child views of that GridView grows, and thus the ScrollView's size is getting larger.In other words,the ScrollView can be scrolled now. The GridView cannot get the focus anymore.

Can anyone help me resolve this tough problem? Thank you.

Leon
  • 29
  • 1
  • 5

2 Answers2

1

GridView itself contains scrollbars so there is no need to put inside the ScrollView.

kalandar
  • 793
  • 6
  • 13
  • Thank you kalandar ,but I have to do it the wrong way this time.Coz the structure of the project cannot be changed and reformed. – Leon Jun 27 '12 at 05:39
0

Romain Guy works in Android team, he suggested not to place a ListView/GridView inside a ScrollView.

Community
  • 1
  • 1
  • Thank you hai bison,but I have to do it the wrong way this time.Coz the structure of the project cannot be changed and reformed. – Leon Jun 27 '12 at 05:40