Android Scrollview Example

If you want to go beyond helloworld application, you need to learn to use Android Scrollview layout. In this tutorial we have Android scrollview example. Let’s start with new blank activity project. In the new blank activity project default layout is RelativeLayout. We need to change it to LinearLayout, but let’s keep RelativeLayout for a while to see the difference. Then add one image view and text view widget. Bellow, put some repeated combination of text view and text fields.  Here how it should look like during designing:

display-layout

However, when you test it on real device, it looks something like this:

layout-on-physical-device

This is consequence of RelativeLayout. So let’s change it to LinearLayout. Now, we have following consequence:

linear-layout-on-physical-device

Now, its a moment to use Scrollview layout. So, add
<ScrollView></ScrollView>
tag in your main XML file. Between these two tags there should be all your widgets. Below scrollview layout put one linear layout.

<LinearLayout

android:layout_width=”fill_parent”

android:layout_height=”fill_parent”

android:orientation=”vertical”>

linear-layout-with-scroll-view

Now it is almost done. What we need is to put as menu linear layouts as many rows we want to have:

android-scrollview-example

Download this project.

External links:

Android Scrollview Example on YouTube
Android Scrollview Example on javatechig
Android Scrollview Example on github
Android Scrollview Example on androidhub4you

Posted in android Tagged with: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*