3

I am creating custom ViewGroup in which I am using onLayout method in which I call the addViewInLayout() of the ViewGroup but it is adding the View only horizontally.

How to force it to add View vertically like ListView is doing for Android

Looking for help.

Vivek Kalkur
  • 2,200
  • 2
  • 21
  • 40
Deepak Goel
  • 5,624
  • 6
  • 39
  • 53

1 Answers1

5

You could try specifying the position via

child.layout(int left, int top, int right, int bottom)

If you have measured the other views in the view group, you should be able to get the bottom of the bottom most view then

child.layout(left, viewAbove.getBottom(),right, viewAbove.getBottom()+heightOfTheChild);
triggs
  • 5,890
  • 3
  • 32
  • 31
  • 1
    Shouldn't the second line be : `child.layout(left, viewAbove.getBottom(), right, viewAbove.getBottom() + heightOfTheChild);` – Saad Farooq Feb 19 '12 at 15:16