0

I have a question that I have a Parent Layout and I am adding many Child Layouts in the parent programmatically and dynamically but when the screen gets filled with child layouts it should automatically scroll down for next child layout which is going to be added in the parent.

Is there any property of scrollview for doing the same. I want the same as default message functionality in the android device. In which views are automatically scrolled up when new message comes. Please suggest any solution regarding this.

Widor
  • 13,003
  • 7
  • 42
  • 64
Sanat Pandey
  • 4,081
  • 17
  • 75
  • 132

1 Answers1

0

The ScrollView class has

scrollTo(int x, int y)

and

smoothScrollTo(int x, int y)

methods that would allow you to move to the position of the child view. To get the position of the child view, see Getting View's coordinates relative to the root layout

Alternately, if you have the option to add views to the top of the parent, you can specify that by passing a 0 index to the addView(View child, int index) method.

Community
  • 1
  • 1
joates
  • 1,103
  • 2
  • 11
  • 22