2

I have an Activity which contains 3 Fragments. And all the 3 Fragments have ListView in them.

I would like to know how to display the 3 Fragments in the ScrollView in same Activity?

Please let me know the solution.

Thanks.

Rami
  • 7,879
  • 12
  • 36
  • 66
Jay Dhamsaniya
  • 323
  • 2
  • 4
  • 15

1 Answers1

0

So I think the the right user experience here is to have only 1 scrolling view, the basic scroll view. The List Views in the fragment should then expanded to take as much space as they need.

The way I accomplished this was to override onMeasure like this

@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.UNSPECIFIED) {
  /**
   * Putting things which like to be scrolled into scrolling views causes bad behavior.
   *
   * The goal here is to simply trick the List view into believing it should fill all available
   * space rather than being undefined.
   */
  heightMeasureSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);

This way you have the 1 scrollable view, and you have 3 expanded list views.

haagmm
  • 583
  • 6
  • 10