Getting Started in Android Development Part 14 - The ScrollView

North Border Software

Home Tutorials Hints & Tips About

Android Apps and Training

Share on Facebook Share on Twitter

Getting Started in Android Development

Part 14 - The ScrollView

As the name implies, the ScrollView allows the screen to be scrolled should the contents of the screen need more than the height or width to be displayed. Without a ScollView the screen would simply truncate the contents without the ability to scroll.

Adding a ScrollView to a layout is straightforward. A ScrollView can only have one child view. This is typically a linear or relative layout. The ScrollView must have the XML name space moved from the child layout to the ScrollView itself or XML errors will be present prior to the name space. The only other consideration is to whether the orientation is set to vertical or horizontal. Our example is shown below. Originally, the Linear Layout was the parent with ten TextViews as child views. The ScrollView was then added as below.

A new activity was set up and the toast in the ListviewActivity file replaced with a new Intent and StartActivity method. After this tutorial your file should look similar to the one below. Don’t forget to update the Android Manifest file to include the new Activity.

The Android Manifest File:

The new file:

Download Download tutorial set 1

© 2015 North Border Software All rights reserved
Privacy and Cookies Terms of Use Disclaimer Copyright
North Border Software Logo