Android Add Views into a ViewGroup Dynamically

As Android developer you will surely  need someday to add views dynamically, instead of creating a ListView. I will show you in this tutorial how to do this 🙂

1. Create a new project and call your activity “MyActivity”
2. Go to res – layout – main.xml and put the following code:

3. Go to res – layout and create a new xml called text_layout.xml and put the following code:

4. Now go to MyActivity class and put the following code:

And now you should have a list with 100 rows that can be scrolled.

Android: Scrolling to the bottom of a ScrollView

Iv’e had a lot of trouble scrolling a ScrollView all the way to the bottom in android and I finally got the way to do it ! Here is the code:

Hope it helps somebody !